Hi,
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) I develop this in C#.
Any small example will be appreaciated, just something for me to start from.
Thanks,
Hi,
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) I develop this in C#.
Any small example will be appreaciated, just something for me to start from.
Thanks,
They are available in Request.QueryString. This is a collection of string key/value pairs, that can also be accessed by ordinal index.
To complete the answer given above with an example:
int id = int.Parse(Request.QueryString["id"]);
OK 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.
For security reasons, be careful with XSS attacks. Please use this library:
http://msdn.microsoft.com/en-us/library/aa973813.aspx
Ex:
String Name = AntiXss.HtmlEncode(Request.QueryString["Name"]);