
12-13-2011, 11:52 AM
|
Junior Contributor
|
|
Join Date: Apr 2005
Location: Albany, GA
Posts: 235
|
|
Response.Redirect() not working
Hello,
I have been pushing to figure out why my Response.Redirect statement will not work. It will work in one portion of the code, but not the other.
Code:
Private Sub btnRegister_Click(sender As Object, e As System.EventArgs) Handles btnRegister.Click
Dim fileName As String = Server.MapPath("dataPath.txt")
Dim objStreamReader As StreamReader
objStreamReader = File.OpenText(fileName)
Dim contents As String = objStreamReader.ReadToEnd()
Dim connectionString As String
Dim strQuery As String
Dim selectedIDValue As Integer = Convert.ToInt32(ddlCourseID.SelectedValue.ToString())
Dim emailAddy As String = Convert.ToString(txtEmailAddress.Text)
connectionString = "Data Source=" & contents & ";Initial Catalog=staffDevelopment;Integrated Security=True;Pooling=False"
strQuery = "SELECT count(*) FROM [Users] WHERE userEmail=" & "'" & emailAddy & "'" & " AND courseID=" & selectedIDValue
Dim emailValidated As Boolean = checkEmail(txtEmailAddress)
Dim count As String
Using conn As New SqlClient.SqlConnection(connectionString)
conn.Open()
Using command As New SqlClient.SqlCommand(strQuery, conn)
command.ExecuteNonQuery()
count = command.ExecuteScalar()
conn.Close()
End Using
End Using
If count > 0 Then
Response.Redirect("alreadyRegistered.aspx")
Else
If emailValidated = True Then
Dim outlookValue As String = ddlCourseID.SelectedValue.ToString
SqlDataSource3.Insert()
Call AddOutlookAppointment(outlookValue)
Response.Redirect("registrationComplete.aspx")
Else
RequiredFieldValidator3.Visible = True
End If
End If
End Sub
The response.redirect() works at this part:
Code:
If count > 0 Then
Response.Redirect("alreadyRegistered.aspx")
Else
But at this portion of the code it does not:
Code:
If emailValidated = True Then
Dim outlookValue As String = ddlCourseID.SelectedValue.ToString
SqlDataSource3.Insert()
Call AddOutlookAppointment(outlookValue)
Response.Redirect("registrationComplete.aspx")
Else
RequiredFieldValidator3.Visible = True
End If
Any suggestions? I have also tried Server.Transfer but it produced the same results.
Thanks,
Cody Wright
|
__________________
Da Vinci - "Sleep is but a waste of time"
|