开发者

Splitting a query string?

开发者 https://www.devze.com 2023-03-24 06:12 出处:网络
this may seem l开发者_运维问答ike a stupid question but I have a query string which passes a unique id across pages, What I am wondering is how I would split the following so that I have just the id?

this may seem l开发者_运维问答ike a stupid question but I have a query string which passes a unique id across pages, What I am wondering is how I would split the following so that I have just the id?

property-buildings_e1.aspx?SubPage=561

Many Thanks!


Request.QueryString("SubPage")


int subPage = 0;
if(Request.QueryString["SubPage"] != null)
    subPage = Convert.ToInt32(Request.QueryString["SubPage"]);


If you want to get the value of SubPage

Request.Params["SubPage"]

or

Request.QueryString["SubPage"]


You can use

HttpUtility.ParseQueryString.

NameValueCollection parts = HttpUtility.ParseQueryString(query);
string subPage = parts["SubPage"];


You should be able to access it using

Request.Querystring("SubPage")
0

精彩评论

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

关注公众号