By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,254 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

How can I submit an ASP.NET web form to a new page

P: n/a
Hi all,

I have used the following code for doing the form
submission. I don't think this is a right way to submit a
from to a new aspx page because I need to add a dummy form
in between.
Could anyone tell me a proper way to do this?

Looking forward to your reply. Thanks!

Chung

My code:

<form id="Form1" method="post" runat="server">
<asp:Button id="Reset_btn" style="Z-INDEX: 125;
LEFT: 853px; POSITION: absolute; TOP: 504px"
runat="server" Width="82px" Height="59px"
Text="Postback"></asp:Button>
<form id="Dummy_Form">
</form>
<form id="Form2" method="post" action="New.aspx">
<INPUT style="Z-INDEX: 105; LEFT: 22px; WIDTH:
224px; POSITION: absolute; TOP: 11px; HEIGHT: 42px"
type="submit" value="Submit to New page">
</form>
</form>
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In .NET your forms submit to themselves (which is called a postback). On
the second (or subsequent page load) you can retrieve the values from your
form elements like this:

Sub Page_Load()
If Not IsPostBack Then 'First time the page is loading

Else 'Second or subsequent time the
page is loading

End If
End Sub

If you want to redirect to another page, use response.redirect,
server.transfer or server.execute.
"Chung" <an*****@hotmail.com> wrote in message
news:08****************************@phx.gbl...
Hi all,

I have used the following code for doing the form
submission. I don't think this is a right way to submit a
from to a new aspx page because I need to add a dummy form
in between.
Could anyone tell me a proper way to do this?

Looking forward to your reply. Thanks!

Chung

My code:

<form id="Form1" method="post" runat="server">
<asp:Button id="Reset_btn" style="Z-INDEX: 125;
LEFT: 853px; POSITION: absolute; TOP: 504px"
runat="server" Width="82px" Height="59px"
Text="Postback"></asp:Button>
<form id="Dummy_Form">
</form>
<form id="Form2" method="post" action="New.aspx">
<INPUT style="Z-INDEX: 105; LEFT: 22px; WIDTH:
224px; POSITION: absolute; TOP: 11px; HEIGHT: 42px"
type="submit" value="Submit to New page">
</form>
</form>

Nov 17 '05 #2

P: n/a
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetjunkies.com/tutoria...tutorialid=600

http://www.dotnetbips.com/displayarticle.aspx?id=79

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"Chung" <an*****@hotmail.com> wrote in message
news:08****************************@phx.gbl...
Hi all,

I have used the following code for doing the form
submission. I don't think this is a right way to submit a
from to a new aspx page because I need to add a dummy form
in between.
Could anyone tell me a proper way to do this?

Looking forward to your reply. Thanks!

Chung

My code:

<form id="Form1" method="post" runat="server">
<asp:Button id="Reset_btn" style="Z-INDEX: 125;
LEFT: 853px; POSITION: absolute; TOP: 504px"
runat="server" Width="82px" Height="59px"
Text="Postback"></asp:Button>
<form id="Dummy_Form">
</form>
<form id="Form2" method="post" action="New.aspx">
<INPUT style="Z-INDEX: 105; LEFT: 22px; WIDTH:
224px; POSITION: absolute; TOP: 11px; HEIGHT: 42px"
type="submit" value="Submit to New page">
</form>
</form>

Nov 17 '05 #3

P: n/a
Thanks Steve,

This really helps me a lot. When I am using the
context.Items control, it comes up another problem. I case
I have 100 textbox in my form then I have to add 100
context items in Context.Items.

Is there any way to get all the form control from my form
at a time? Then I can use foreach loop to get all the
value.

Chung
-----Original Message-----
Here's a nice, simple way to pass values from one page to another:(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items ("myParameter"),Integer)
Of course there are a number of ways to pass values from one page toanother, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.You'll have to decide which technique is best for your application.Here are several good articles on the subject to help you decide.http://msdn.microsoft.com/msdnmag/is...04/ASPNETUserS tate/default.aspx
http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetjunkies.com/tutoria...tutorialid=600

http://www.dotnetbips.com/displayarticle.aspx?id=79

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able- consulting.com
"Chung" <an*****@hotmail.com> wrote in message
news:08****************************@phx.gbl...
Hi all,

I have used the following code for doing the form
submission. I don't think this is a right way to submit a from to a new aspx page because I need to add a dummy form in between.
Could anyone tell me a proper way to do this?

Looking forward to your reply. Thanks!

Chung

My code:

<form id="Form1" method="post" runat="server">
<asp:Button id="Reset_btn" style="Z-INDEX: 125;
LEFT: 853px; POSITION: absolute; TOP: 504px"
runat="server" Width="82px" Height="59px"
Text="Postback"></asp:Button>
<form id="Dummy_Form">
</form>
<form id="Form2" method="post" action="New.aspx">
<INPUT style="Z-INDEX: 105; LEFT: 22px; WIDTH:
224px; POSITION: absolute; TOP: 11px; HEIGHT: 42px"
type="submit" value="Submit to New page">
</form>
</form>

.

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.