Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send parameter to another ASP.Net page

I have class in c# called "Point".

public class Point(){
.
.
}

In page1.aspx I created:

Point p1 = new Point();

I want to send it to page2.aspx. I try to send with:

Response.Redirect("~/page2.aspx?x=p1");

And get it in page 2 with:

Point p2 =Request.QueryString["x"];

It does not work. Can you help me please?

like image 497
Or K Avatar asked Dec 15 '22 03:12

Or K


1 Answers

Aside from the fact that you cannot just put "p1" in a string and have it reference a class instance, you cannot just add an object as a query argument.

You will need to add arguments to the URL for each element of Point. For example:

Response.Redirect(String.Format("~/page2.aspx?x={0}&y={1}", p1.x, p1.y));

Alternatively, you could use Session if you don't need it as a query argument.

like image 78
Jonathan Wood Avatar answered Dec 30 '22 11:12

Jonathan Wood