ASP.NET 2.0 : Passing data between Pages

Hi,

One of the hinderances we had in earlier verions of ASP.NET (1.1 & 1.0 versions) were that, to pass data between pages, we need to use QueryString, Server.Transfer, Sessions etc.,. This was a little surprising for people who come from ASP background who are used to <form method="post" action="newpage.asp">

They can easily get values using Request.Form and posting to new page was as simple as specifying in the action tag the page where they want to post.

However, in ASP.NET, by default all the pages post to themselves. That means, you cannot set the action page and if you want to do so, you need to remove the "runat=server" attribute which will disable the other extraordinary features provided in .NET. So naturally passing values between pages was a little tricky.

In Whidbey, the developers have listened to the queries and come up with a wonderful solution, i.e. the PostBackUrl property.

The PostBackUrl specifies which page to be posted to, upon submitting the page. The syntax is as follows:-

<asp:Button ID="button1" Runat=server Text="submit" PostBackUrl="~/NewPage.aspx" />

Thats it! Now when the button is clicked, the page is posted to the "NewPage.aspx".

You can now use the Request.Form to get the value(s) from the previous page.

That really addresses many people's query on the earlier versions.

There is another exciting way to access the previous page's controls which I will write about in my next article.

Cheers and Happy Programming !!!

posted @ Monday, April 25, 2005 8:01 AM

Print

Comments on this entry:

# re: Whidbey: Passing data between Pages

Left by Anand Kumar Tripathi at 3/3/2007 7:17 PM
Gravatar
That's Greate and thanks to give the great information .
I am new in .net and programming filed that's while i wana some more solution on tha .NET .
So Please Help me in programming.
Thanks Again .
Anand Kumar Tripathi .
anandtri@gmail.com

# re: ASP.NET 2.0 : Passing data between Pages

Left by Goutam at 10/28/2008 3:11 PM
Gravatar
Hi Guys

# re: ASP.NET 2.0 : Passing data between Pages

Left by şişme bebek at 11/20/2008 1:14 PM
Gravatar
That's Greate and thanks to give the great information .
I am new in .net and programming filed that's while i wana some more solution on tha .NET .
So Please Help me in programming.

# re: ASP.NET 2.0 : Passing data between Pages

Left by erotik shoph at 11/25/2008 3:23 AM
Gravatar
That's Greate and thanks to give the great information .
I am new in .net and programming filed that's while i wana some more solution on tha .NET .
So Please Help me in programming.
Thanks Again .
Anand Kumar

# re: ASP.NET 2.0 : Passing data between Pages

Left by mario oyunları at 9/21/2009 10:41 AM
Gravatar
i am new in .net and programming filed that's while i wana some more solution on tha .NET .

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345