开发者

How to pass QueryString param to PageMethods?

开发者 https://www.devze.com 2022-12-21 07:02 出处:网络
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.

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 ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号