473,395 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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
3 2246
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Matt | last post by:
I want to submit the form to the server without opening another page. When we do the following, it will submit the form data in myform to the IIS, and open page2.asp. <form name="myform"...
2
by: Terence Parker | last post by:
How does one go about submitting a form with a link - but submitting it to a new window AND to a page different to that described within the action="" option of the <form> tag? Say, for example,...
15
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
6
by: CJM | last post by:
Can somebody clarify if/how/when a simple form is submitted when the <Enter> key is pressed? As I understood it, if you have a form with a single submit button, if enter is pressed, the form...
5
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform'...
9
by: Eric George | last post by:
Hi, Has anyone had any success using jscript submit method in their VS.NET projects? For example I have some client processing in a script function then call <form name>.submit(); This won't...
1
by: kkuniya | last post by:
Situation : - A form (method : POST, action : itself, onsubmit : alert 'Submit' ) - Got 2 submit button ( 'Save' , 'View') - Got navigation 1|2|3|4 What I want to do : - Once clicked on the...
5
by: Alex | last post by:
Hello, I hope I can explain this properly. I'm writing an application with a tabbed-based navigation, and a form which gets filled out by users will be split into 5 subtabs. What I need is...
4
by: j1dopeman | last post by:
Hi, I'd like to use a button to save and then submit a form. I can set the onlick of the button to mahButton_click or submit, but I can't figure out how to do both. It looks like c# can't...
13
Frinavale
by: Frinavale | last post by:
I've been trying all morning to cancel a form submit to the server. I have a JavaScript Object that determines whether or not the page should be submitted to the server depending on whether the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.