What is right way to send visitors from one webform to other webform
What is right way to send visitors from one webform to other. What are their limitations and their plus points. Please explain.开发者_如何学JAVA
One way is to provide a link, which the user has to click:
<a href="Step2.aspx">Next Step</a>
This sends the user to step 2 directly, without any opportunity to do anything in between/
Another way is to simply redirect the response:
Response.Redirect ("Step2.aspx");
This will directly send the user to step 2 and is typically used when some processing needs to be done before going to step 2.
You could also use a meta tag to redirect
<meta http-equiv="refresh" content="2; url=Step2.aspx">
When a delay is required, this is the usual way. The current form simply displays an "accepted" message and then directs to a new page.
Setting the action attribute of the form element is an alternative:
<form id="form1" runat="server" action="Step2.aspx">
This approach is usually used when the second steps uses some data posted from the first step.
I'm sure there are plenty of other ways, but these are the few common ones that I use.
The big question is what do you mean by "send"? @Fun Mun Pieng covered redirect, which is the right way to do things if you want to give the user the same experience as if they clicked a link and visited a different webform.
If, however, you want to preserve all of the form values, effectively posting back to a different webform, then you want to look at Server.Transfer("redirectForm.aspx")
. The clue to what it's doing different from Response.Redirect("redirectForm.aspx")
is in the object you're manipulating. Response.Redirect() is sending an instruction down to the browser, as a response, directing it to lodge a separate request for a different resource. Server.Transfer() is highjacking the current request and giving control over to a different page without the browser ever knowing about it. They may seem similar, but this is a HUGE difference...
精彩评论