Send form data to another page

  • Thread starter Thread starter Andrea De Santi
  • Start date Start date
A

Andrea De Santi

How can I redirect to another page with form data?
In asp Classic I write:
<form ... action="filename">...</form>
and in then target page I write
<%=request.form("fieldname")%>

.....
but in ASP.NET 1.1 'action' does not exist
how can I send form data to another page?... and how can I read a form
values (same of ASP classic with request.form("fielsname")?)

Thanks
Andrea

Sorry I know that is stupid question, but I try to translate ASP Classic App
to ASP.NET
 
Andrea,

You can still use the functionality in .Net to post a form to another page. However you can not use the Server controls since you will be bypassing the plumping you just use html controls like you would in classic asp.


-Calvin Luttrell
ProjectThunder.com, Inc.
nothing is impossible
 
The action attribute cannot be used if you are using a form with the
runat=server attribute. The default model for asp.net is to have the page
postback to itself and then you handle any redirect upon post back with
response.redirect() or server.transfer(). If you still would like this,
then you cann't use the asp.net webcontrols as your form controls. You must
revert back to HTML form controls.
 
That's called Cross Page Posting (may help with searching).

They moved away from that with ASP.NET 1.0 and 1.1, but it's being
added back in for ASP.NET 2.0. Until then, it's not easy to do with
ASP.NET 1.1. I'd recommend converting to a single page with panels - it
seems to fit more smoothly with the way the ASP.NET framework is
designed to work.

This page has some good information on that approach:
http://www.dotnetjohn.com/articles.aspx?articleid=160

Another option is to post back to the first page, save the form
variables, and go to the second page. You can either add the form
variables to the HttpContext and use Server.Transfer, or add them to
the Session and Redirect. Using HttpContext keeps your session
uncluttered, but you can't use it with Redirect.

If you're determined to post to another page, you can circumvent the
postback mechanism with some javascript. It's a little more complex
than you'd think, since ASP.NET sees this as an attempt to hack your
site by tampering with form Viewstate. Here's an article on that:
http://www.codeproject.com/aspnet/jsnopostback.asp

Hope that helps.

- Jon
http://weblogs.asp.net/jgalloway
 
Back
Top