1

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

enter image description here

ifaminsi
  • 183
  • 3
  • 20

4 Answers4

1

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&param2=world
BendEg
  • 20,098
  • 17
  • 57
  • 131
0

Your page url should be something like this for your code to work

yoururl\mypage.aspx?Parameter=1

Rajeev Kumar
  • 4,901
  • 8
  • 48
  • 83
0

You could also get the parameter like that if you use post/get:

String name = HttpContext.Current.Request.Params["name"];
kaliba
  • 230
  • 2
  • 12
0

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

https://msdn.microsoft.com/en-us/library/6c3yckfw.aspx

pubudut
  • 603
  • 2
  • 8
  • 18