How to redirect the site visitor?

keymaker

Member
Joined
Aug 13, 2014
Messages
12
Programming Experience
Beginner
Hello

I have the following in my aspx.vb file (it's a new user registration form on a Web site):

VB.NET:
Protected Sub CreateUser_Click(ByVal sender As Object, ByVal e As System.EventArgs)

                   Using conn As OleDbConnection = New OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings("students").ConnectionString)


                Dim Sql As String = "INSERT INTO university (username,[password], strEmail) VALUES (@username,@password, @strEmail)"


                Dim cmd As New OleDbCommand(Sql, conn)
                conn.Open()
                cmd.Parameters.AddWithValue("@username", username.Text)
                cmd.Parameters.AddWithValue("@password", password.Text)
                cmd.Parameters.AddWithValue("@strEmail", strEmail.Text)


                cmd.ExecuteNonQuery()
                conn.Close()


            End Using


           End Sub

The code work - locally, at least - but when the user clicks the Register/Submit button he is not redirected anywhere so he doesn't know if his registration has been successful or not.

If possible I would like to introduce a piece of code that says 'if the user is successful redirect here' otherwise 'go back to the new user registration form'. I imagine that would involve a 'If....else' statement. I am just unsure how to write it exactly or where to place it in my code. Does it require another aspx page or can I include it in the code I have posted above?

Thank you.

Keymaker
 
I don't want to discourage anyone from using forums in general or this forum in particular, but they really should be your last line of defence, used when you can't find what you need or can't understand what you find, not a first option so that you don't have to bother looking. I just did a quick web search and found numerous posts and the like that answered your question, either directly or indirectly. As they all say, you simply call Response.Redirect.
 
Back
Top