I am trying to pass parameter from one page to another. In my second page I cant access that parameter. i am new to asp. Please help me
-
1[What is a `NullReferenceException` and how do I fix it?](http://stackoverflow.com/q/4660142/447156) – Soner Gönül Dec 23 '15 at 07:13
-
And please show your work and exception message as a plain text, not as an image. – Soner Gönül Dec 23 '15 at 07:13
-
Please let us know URL format with parameters and one more thing that Request.QueryString["whatever"] always returns string so no need to convert it to string . – Jaydip Jadhav Dec 23 '15 at 07:57
4 Answers
In your case, the QueryString
seems not to contain the parameter Parameter
, so it return null
and null
has no ToString()
method.
Try:
var param = Request.QueryString["Parameter"];
if(param != null)
{
string yourValue = param.ToString();
}
Hope this helps.
If you want to know, which url parameter are passed, you can take a look at Request.QueryString
, becaus it contains all parameter. Be sure your are encoding them correctly in the URL:
www.example.com/home.aspx?param1=Hello¶m2=world

- 20,098
- 17
- 57
- 131
Your page url should be something like this for your code to work
yoururl\mypage.aspx?Parameter=1

- 4,901
- 8
- 48
- 83
You could also get the parameter like that if you use post/get:
String name = HttpContext.Current.Request.Params["name"];

- 230
- 2
- 12
Assume you have two pages PageWithParameter.aspx and PageRecievingParameter.aspx
Then you will be sending parameter from pageWithParameter.aspx in this manner
http://www.example.com/pageWithParameter.aspx?parameter1=value1
in the pageRecievingParameter.aspx code behind you will get the value of the parameter like this
String s = Request.QueryString["parameter1"];
For more information please refer into msdn

- 603
- 2
- 8
- 18