Passing Variables from folder aspx files

Posted by Lokeshbasana under ASP.NET on 3/6/2009 | Views : 1553 | Status : [Member] | Replies : 3
My code is
Default.aspx code is
int a = 3;
Response.Redirect("Default2.aspx?=" + a.ToString());

Default2.aspx code is
int orderid = int.Parse(Request.QueryString["a"].ToString()); //Getting Error(Object reference not set to an instance of an object.)




Responses

Posted by: Neeks on: 3/6/2009 [Member] Bronze

Up
0
Down
Hi Lokeshbasana,
You cannot pass Integer as an argument in Response.Redirect(...).

You have to convert it in string.

And you can get back to your desired page.

Your code can be...
Response.Redirect("Default.aspx?a=" + a.ToString());

int orderid = int.Parse(Request.QueryString["a"].ToString());


Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 3/6/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down

You can do this
[code]
int a = 3
Session["a"] = a;
[/code]

and in your second page

[code]
int orderid = (int) Session["a"];
[/code]

Please Note: Lokeshbasana everytime when you post a code, put it between [code]my code........[/code] i look neat.

Thank you



Thank you for posting at Dotnetfunda
[Administrator]

Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lokeshbasana on: 3/6/2009 [Member] Starter

Up
0
Down
its working fine Neeks thank u
Response.Redirect("Default.aspx?a=" + a.ToString()); // correct

for small thing i forget i didn't assign passing variable
i.e default2.aspx?a= but i written default2.aspx?=
Response.Redirect("Default2.aspx?=" + a.ToString()); // Error


Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response