Response.Redirect() not working
Response.Redirect() not working
Response.Redirect() not working
Response.Redirect() not working
Response.Redirect() not working
Response.Redirect() not working Response.Redirect() not working Response.Redirect() not working Response.Redirect() not working Response.Redirect() not working Response.Redirect() not working Response.Redirect() not working Response.Redirect() not working
Response.Redirect() not working Response.Redirect() not working
Response.Redirect() not working
Go Back  Xtreme Visual Basic Talk > > > Response.Redirect() not working


Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2011, 12:52 PM
jaden2001 jaden2001 is offline
Junior Contributor
 
Join Date: Apr 2005
Location: Albany, GA
Posts: 235
Default 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"
Reply With Quote
  #2  
Old 03-10-2012, 03:42 AM
zeeshanef zeeshanef is offline
Newcomer
 
Join Date: Mar 2012
Posts: 1
Default

Try to redirect the page, out side the IF.

Code:
Dim RegCompRedirect as boolean = false 'this

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)
                RegCompRedirect=True 'this
		
            Else
                RequiredFieldValidator3.Visible = True
            End If

End If


If RegCompRedirect=True then 'this
	Response.Redirect("registrationComplete.aspx")
End If

End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Response.Redirect() not working
Response.Redirect() not working
Response.Redirect() not working Response.Redirect() not working
Response.Redirect() not working
Response.Redirect() not working
Response.Redirect() not working Response.Redirect() not working Response.Redirect() not working Response.Redirect() not working Response.Redirect() not working Response.Redirect() not working Response.Redirect() not working
Response.Redirect() not working
Response.Redirect() not working
 
Response.Redirect() not working
Response.Redirect() not working
 
-->