Form action attribute unchangeable?

B

belgie

Whereas in Asp I could submit my form contents to any other Asp page, it
appears that in Asp.NET the primary Asp form will only submit to itself.

I have tried changing the Action attribute in the Form tag, but it changes
itself back when compiled.

I have also tried changing the form Action attribute in client-side
javascript prior to submitting the form, but I get this error:
The View State is invalid for this page and might be corrupted.

I can pass the form collection to a different Asp page by creating
properties in the page module and using Server.Transfer. I can also do it
using client-side logic, by creating a second form on the page with whatever
Action attribute I desire, and copy the data from the primary form to hidden
controls on the secondary form before submitting it.

Am I correct that there is no simpler way of accomplishing what was a common
task in old Asp?

I am otherwise happy with ASP.NET so far. I can manage my interface in a
single page, but it is a lot of panel moving and hiding. (I have found the
best way to do this is with an HTML Grid Layout panel, with the RunAt
property set to Server.)

Please let me know if it seems I have overlooked something.

Thanks!
Bill
 
S

S. Justin Gengo

Belgie,

This is a trade off that was made in order to bring web programming into the
modern world of object oriented programming.

It took me a while to get used to it too...

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
C

Chris Jackson

You can change this behavior to submit to another page by removing the
runat="server" attribute from the form tag. However, you then lose the
ability to work with web controls.

With ASP.NET, you work with declared controls and inheritance. The post back
can then be used to read from these same controls and take some action. It
is a fundamental difference in how you construct your applications - once
you get used to it, it seems very natural. You react to events. You may not
want to post to another form yet - you may have validators that you want to
run before you leave that page, and you can't trust that this happens in
client side code.

If you have several pages, don't forget that you can also response.redirect
and server.transfer, rather than having to use panels and such.

Also, you have the ability to dynamically load controls. I have quite a few
applications that consist of a single aspx page, and the content is
determined by which ascx pages I have loaded into it at a given time. You've
just got to think about things a little bit differently.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top