Click here to Skip to main content
15,885,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can I ask, please, if this page redirection might work? I can't test it yet because the project is not compiled or uploaded to a server but a second opinion would be welcome.

I have this in my HTML form:

<asp:TextBox ID="your_name" runat="server"></asp:TextBox></p>


and this in my aspx.vb file:

Protected Sub contact_submitted_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles contact_submitted.Click

 Dim Name As String = "yourname"

 'Request.Form - extract data from form fields

  Dim yourname As String = Request.Form("your_name")

'Redirect the user after SMTP form sent

 Dim target = String.Format("~/thankyou_test.aspx?your_name={0}", Name)

 Response.Redirect(String.Format("~/thankyou_test.aspx?your_name={0}", Name), True)

 'Redirect the user

  Response.Redirect(target, True)


Many thanks
Posted

1 solution

Yes, it will work although the code is not very simple.

1. If you are posting back the same form you can get the textbox value by using
C#
your_name.Text
instead of using Request.Form.
2. You have 2 calls to Response.Redirect. Only 1 will work. Response.Redirect means go to this page.
3. You String.Format into a variable named target but then don't use it right away.

Minor things, but clean code is easier to debug and to understand.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900