How to pass QueryString param to PageMethods?
Is there a way I can pass querystring param to PageMethods? I have this requirement because inside the AjaxMethod I am using some classes which rely on a particular querystring being present.
If I am using Asp.Net ScriptManager, PageMethods is there a way to pass the querystring param from the javascript to the Ajax Web Method?Example : I have to access the Query Param as shown below.
[WebMethod(true)]
public static string AjaxMethod(string name)
{
string Id = HttpContext.Current.Request.QueryString["SomeID"];
retu开发者_JAVA技巧rn message + " " + name;
}
Use window.location.search
for passing the query string (you might want to remove the first character - the question mark).
If you want to use not the query string of the current page, but append some query string to a URL of a page method, you probably have to use some wrapper for the ajax callback. I don't think this functionality is supported by the generated proxy. We have used the same approach for our project to be able to cancel the page method call - just use some jquery / prototype wrapper and you have more expression power ;)
精彩评论