Action on a form in Dot Net

D

Don Parker

I am a newbie to ASP.NET. I am converting some asp pages I had working.
I have a page which has a form with several input elements. When the
user clicks on a Submit element - the action specified in the form tags
is to post the data to a new page. What happens however is that the
original page simply reloads. How do I force it to post to the new page
instead. (I suspect the problem may be the runat server directive? I
had to use that to populate my dropdowns with databinding)

Here is the form declaration:

<form method="post" name="churchform" id="churchform"
action="localstuffPostData.aspx"
runat="server">
 
S

Shiva

I have not tried this, but you might want to take a look:
http://www.codeproject.com/aspnet/jsnopostback.asp


I am a newbie to ASP.NET. I am converting some asp pages I had working.
I have a page which has a form with several input elements. When the
user clicks on a Submit element - the action specified in the form tags
is to post the data to a new page. What happens however is that the
original page simply reloads. How do I force it to post to the new page
instead. (I suspect the problem may be the runat server directive? I
had to use that to populate my dropdowns with databinding)

Here is the form declaration:

<form method="post" name="churchform" id="churchform"
action="localstuffPostData.aspx"
runat="server">
 
S

Steve C. Orr [MVP, MCSD]

In ASP.NET 2.0 changing the form action will be easy. However, setting the
form action attribute just isn't the ASP.NET 1.x way. If you must do it
precisely that way the you can change the action attribute using client side
script or you can define a form without the runat=server attribute (in which
case it will act a whole lot like classic ASP.)

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/issues/03/04/ASPNETUserState/default.aspx

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

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

Here's one nice, simple way to pass values from one page to another:

'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)
 
D

Don Parker

Thanks for the great information! I guess the easiest thing to do is
just postback to the original page. I always liked to keep them
separate for clarification in the past with ASP but with code behind now
- I guess that situation is not a big deal. Thanks again. I'm afraid
I'm trying to write ASP code in ASP.NET.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top