how ASP.NET page gets user input from another ASP.NET page??

M

Matthew Louden

In ASP, if I have asppage.asp for GUI and aspprocess.asp for process
requests from database.

In asppage.asp code will be like:
<form action="aspprocess.asp" method="POST"> GUI CODE </form>

When the user clicks the submit button on asppage.asp, it will invoke
aspprocess.asp page

aspprocess.asp code can get the user input from asppage.asp by doing:
Request.Form("Control_ID")

In ASP.NET, if I want to achieve the same goal: if I have aspxpage.aspx for
GUI and aspxprocess.aspx for process requests from database

In aspxpage.aspx code will be like:
<form id="Form1" method="post" action="aspxprocess.aspx" runat="server"> GUI
CODE </form>

However, when the user clicks the submit button on aspxpage.aspx, it didn't
invoke aspxpage.aspx page at all, unless I do the the following:

Private Sub Submit1_ServerClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Submit1.ServerClick
Response.Redirect("aspxprocess.aspx")
End Sub

But even now I am in aspxprocess.aspx page, how can I get the user input
from aspxpage.aspx??
Request.Form("Control_ID") no longer works.

Please advise!
Thanks!
 
S

Steve C. Orr [MVP, MCSD]

Setting the form action attribute just isn't the ASP.NET way.

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserState/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=600

http://www.dotnetbips.com/displayarticle.aspx?id=79

Here's one nice, simple way to pass values from one page to another:

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)
 
S

Steve Nihan

Not sure if this is what you're looking for...but... In all of my aspx
pages that needed processing...I've used codebehind pages to process the
form. Makes things alot easier, simpler, and faster. Simply tie the submit
button to a sub which processes the data you're trying to move. It's
already on the page....so calling the code behind page will just be a matter
of:

Dim uEmail as string = Email.Text

There's just so much to do using that method...and there are quite a few
books out there already...so I don't want to aggrivate people by writing one
here....LOL
 
F

Fahad Al Hadhrami

In ASP. Net You Can not submit your page to another form. It always post
back to the same page.

Here are three links that will help you solove your probelm.

They are many solutions. But I will tell you one of them. It is called
QueryString.

Sub Button1_Click(sender as object, e as EventArgs)
Response.Redirect("asppage.aspx?name=" & name.Text)
End Sub

And in the process page you can call it by

Sub Page_Load(sender as object, e as EventArgs)
Request.QueryString("name")
End Sub

For more information you can visit.

http://www.stardeveloper.com/articles/display.html?article=2003061901&page=1
http://www.dotnetbips.com/displayarticle.aspx?id=79
http://authors.aspalliance.com/wisemonk/print.aspx?id=AN012522

Regards,
Fah@d ;)
 

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,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top