How do I get a form to post to another page when runat="server" is true?

C

COHENMARVIN

I'm a asp programmer starting out with asp.net. I understand that an
asp form can post to its own page and that this allows validation of
form fields on the server. But suppose all the controls turn out to be
valid, and now I want to move to a new page?
My form declaration looks like this:
<form METHOD="POST" ACTION="sites2.aspx" name="MyForm" runat="server">
This form declaration is on a page called sites1.aspx, but it doesn't
post any data to sites2.aspx. In fact, "sites2.aspx" doesn't show up
at all, instead I keep getting sites1.aspx every time I click on the
SUBMIT button.
What am I doing wrong?
Thanks,
CohenMarvin
 
M

Marina

But if the validation is happening on the server, that means the page has
already posted back to itself. So the Action was pointing to the current
page.

I dont' really understand what you are trying to do here.

I would recommend you throw out 95% of the techniques you used to get things
done in ASP. They will typically only lead you down the wrong path.

Your page should validate its own data, and process it. Once it is done, it
should redirect to the next logical page in your application. This page
should follow the same model. Every page is typically self contained - it
does not need the help of any other page to do its processing.

Hope that helps.
 
G

Guest

SO true... in the page_load event you should use the If logic as follows

If Not IsPostback then
load page for the first time
else
validate process
SERVER.TRANSFER("page2.aspx")
end if
 
M

Marina

Or more typically, there is some sort of button click handler, or something
like that. So depending on what button go clicked or what not, the
processing may be a bit different.

But that's the general idea.
 
S

Scott Allen

There is no inherent support for cross page postbacks until v2.0 of
ASP.NET. See:

Design Considerations for Cross Page Post Backs in ASP.NET 2.0
http://odetocode.com/Articles/421.aspx

You can still use a couple techniques in the article to get to the
other page, including Response.Redirect and Server.Transfer.
 

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

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top