Reputation:
I'm new to ASP.net, how can I read parameters passed from ASP.net page (http://website.com/index.aspx?id=12&nam=eee).
Any small example will be appreciated, just something for me to start from.
Upvotes: 5
Views: 20523
Reputation: 29157
Using your sample URL:
string id = Request.QueryString["id"];
string nam = Request.QueryString["nam"];
Read about Request.QueryString on MSDN. You probably want to convert the id
value to an int.
Upvotes: 10
Reputation: 46415
They are available in Request.QueryString
. This is a collection of string key/value pairs, that can also be accessed by ordinal index.
Upvotes: 0
Reputation: 465
For security reasons, be careful with XSS attacks. Please use this library:
http://msdn.microsoft.com/en-us/library/aa973813.aspx
Example:
String Name = AntiXss.HtmlEncode(Request.QueryString["Name"]);
Upvotes: 3
Reputation: 1
string st1=Request.QueryString["t1"].ToString();
string st1=Request.QueryString["t1"].ToString();
int a=Convert.ToInt32(st1)+Convert.ToInt32(st2);
Response.Write(a);
Upvotes: 0