Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server Side Form Tag (Action)

Status
Not open for further replies.

VBRookie

Programmer
May 29, 2001
331
US
Is there a way to change the action of the form tag programmtically? Like from the code behind file?

I tried something like form.action = "whatever.aspx" but its not acceptable. I looked on MSDN for all the members of the htmlform library and action doesn't show up.

Any Ideas?

- VBRookie
 
a form with "runat=server" cannot have its action changed. It does a post-back every time no matter what you set it to be.

If you want to use your vars on another page, then either use a classic html form, or figure out a way to maintain the state of post back variables (session, querystring, database, temp file, just to name a few) and do a redirect, or you could examine the use of asp:panel on your page to make it appear as though the page has changed, when it really has not.

good luck :)
paul
penny1.gif
penny1.gif
 
So then if this is the case then you cannot use hidden form fields in ASP.NET to maintain state because you would have to be able to post the data to the next form.

Correct?

- VBRookie
 
Well, the need for hidden form variables are far decreased in asp.net.

First of all, asp.net does a fine job of maintaining state on post backs all by itself. You don't need hidden form variables to do it.

Second, yes... they won't post to another page, unless you put them into a second form on the page (which you COULD do if you felt inclined).

I still use them from time to time to facilitate client side javascript which has an easier time reading from and writing to these types of variables, rather than asp.net's funky named variety.

So the answer is... sort of.

<sheepish grin>

paul
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top