This is a QueryString variable so you will access it through the QueryString
collection
You'll need to test for a null value to start with before assigning it
if(Request.QueryString["testid"] != null)
something =
Convert.ToInt32(Request.QueryString["testid"].ToString());
The value of the testid is probably a number, so you'll need to convert
it from a string into something else. I tend to add the ToString() onto a
lot of collection operations simply to be sure. You never know when you'll
have a collection that will be a collection of objects instead of strings
and will throw an error. Also, this code doesn't test to ensure that it's a
valid integer varable before it tries the convert function.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Jeff" <it_consultant1@NO_SPAM.hotmail.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hey
asp.net 2.0 (C#)
Retriving value:
In my webpage, I need to retrieve a value from the URL, this is a
parameter stored in the url, like this: www.helloworld.com?testid=34
what C# code shall I use to retrive this testid value?
Setting value:
Another thing I'm wondering about is what C# code shall I use to set the
testid value to the URL, lets say I want to add the testid parameter to
the URL, what C# code shall I use to do that?
Jeff