I've posted this problem on several forums and no one has come up with the correct answer, but anyway here it goes:
I've tried stringifying and querystring'ing the parameter but the Response error continues to be
{"Message":"Object reference not set to an instance of an object.","StackTrace":" at ProvaReportLocale._Default.GetColumns() in \\ProvaReportLocale\\Default.aspx.cs:line 96","ExceptionType":"System.NullReferenceException"}
I have the following JSON call, the data I'm passing seems to be getting stringify'ed properly from what i'm looking at, however, I don't seem to have the right syntax to process the parameter in the public web method.
Here is the JSON call:
<script type="text/javascript" language="javascript">
var qs = new Querystring();
var v1 = qs.get("TorVName");
var jsonData = JSON.stringify(v1);
$().ready(function() {
$.ajax({
type: "POST",
url: "Default.aspx/GetColumns",
data: jsonData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
var optString = '<option value="-1">Select Column</option>';
$.each(msg.d, function(index, item) {
optString += '<option value="' + item + '">' + item + '</option>';
});
$('select[name^=DDLColumns]').html(optString);
},
error: function() {
alert("Failed to load columns");
}
});
});
</script>
and here is the cooresponding web method:
[WebMethod]
public static ArrayList GetColumns(string TorVName)
{
String cnstr = "myconnect string";
string Sql = String.Empty;
ArrayList arlist = new ArrayList();
SqlDataReader rdr = null;
SqlCommand cmd = null;
DataSet dset;
SqlConnection cn = new SqlConnection(cnstr);
cn.Open();
dset = new DataSet("ds");
dset.Clear();
etc etc...
The whole thing works if I hard code the variable TorVName = "Whatever";
even passing back to the html page the ArrayList through json, so this is the last piece of the puzzle.
I have a hard time deciding how to debug a web method since I can only see the client side actions in firebug.
any help on how to recieve and process the parameter in the web method would be most appreciated.
Thanks Deano