Send form data to another page

  • Thread starter Andrea De Santi
  • 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
 
C

Calvin Luttrell

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
 
T

Tampa.NET Koder

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.
 
J

jongalloway

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
 

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,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top