I am trying to pass the a string to my behind code, but its always null.
$.ajax({
type: "POST",
url: "Search.aspx?do=SearchText",
data: {searchText: searchText },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: fnsuccesscallback,
error: fnerrorcallback
});
protected void Page_Load(object sender, EventArgs e)
{
if (Request["do"] != null && Request["do"] == "SearchText")
{
string result = Search.searchText(Request["searchText"]);
}
}
My Request["searchText"] is always null.
EDIT:
public void DoSearch(string SearchText)
{
string result = Search.searchText(SearchText);
}
and in the ajax post:
url: "Search.aspx/DoSearch",
data: { searchText: searchText },