Possible Duplicate:
Get query string values in JavaScript
What is the best way to get "test1" from
http://localhost:3311/blabl/allprofiles.aspx?username=test1
, and through PageMethod pass it to webmethod. I think one way is to take from window.location.pathname, cut the string and pass it like a parameter.
May be you can use only javascript like:
var search = function(){
var s = window.location.search.substr(1),
p = s.split(/\&/),
l = p.length,
kv, r = {};
if(l === 0){return false;}
while(l--){
kv = p[l].split(/\=/);
r[kv[0]] = kv[1] || true;
}
return r;
}();
Then use in your code search.username
Try
string username = Request.QueryString["username"];
In a PageMethod, you can do
string username = HttpContext.Current.Request.QueryString["username"];
精彩评论