locked
help on redirect to the last page update in database RRS feed

  • Question

  • User1325920427 posted

    Hi,

    I really need help on to redirect page:

    1) if the last page in database is null ---> the redirect page will automatically appoint user to the first page

    2) if if the last page in database is page 3 ---> the redirect page will automatically appoint user to the third page

    i already run the code, i still can get the right result, when i debug, i found 

    whenever i write

    If strLastPAGE = "" Then

    --> this will redirect page to the last page update in database

    but when i change the code

      If strLastPAGE = "0" Then

    --> this will redirect page to the first page whitout taking the value last page update in database

    here i place the code so far:

      Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    
            strSQL = "SELECT LoginID FROM UserMark WHERE LoginID='" & oCommon.FixSingleQuotes(txtEmail.Text) & "' AND Pwd='" & oCommon.FixSingleQuotes(txtPassword.Text) & "'"
            If oCommon.isExist(strSQL) = True Then
    
                Response.Cookies("islogin").Value = "Y"
    
                ''get userid and surveyid
    
                strSQL = "SELECT UserID FROM UserMark WHERE LoginID='" & oCommon.FixSingleQuotes(txtEmail.Text) & "'"
                strUserID = oCommon.getFieldValue(strSQL)
    
                strSQL = "SELECT SurveyID FROM UserMark WHERE LoginID='" & oCommon.FixSingleQuotes(txtEmail.Text) & "'"
                strSurveyID = oCommon.getFieldValue(strSQL)
    
            Else
                Response.Cookies("islogin").Value = "N"
                lblLoginMsg.Text = "Invalid Login ID or Password. Please try again."
            End If
    
            '' validate last page update
            Try
                If validateLastPage() = False Then
                    Exit Sub
                End If
    
            Catch ex As Exception
    
            End Try
    
        End Sub
    
        Private Function validateLastPage() As Boolean
    
            Dim strNextpage As String = "esurvey.default.aspx?userid=" & strUserID & "&surveyid=" & strSurveyID & "&culture=en-US&" & Request.QueryString("culture")
    
            strSQL = "SELECT LastPage FROM UserMark WHERE LoginID='" & strUserID & "'"
            strLastPAGE = oCommon.ExecuteSQL(strSQL)
    
            If strLastPAGE = "" Then
                Response.Redirect(strNextpage)
                Return False
            Else
                strSQL = "SELECT LastPage FROM UserMark WHERE UserID='" & strUserID & "'"
                strLastPAGE = oCommon.getFieldValue(strSQL)
                Dim notCompletePage As String = strLastPAGE & "?userid=" & strUserID & "&surveyid=" & strSurveyID & "&culture=en-US&" & Request.QueryString("culture")
                Response.Redirect(notCompletePage)
                Return False
            End If
    
            Return True
    
        End Function


    really need help on urgently . thank you so much

     

    Friday, April 20, 2012 12:39 AM

Answers

  • User1046077057 posted

    Hi,

    What do you mean of doesn't work? If you want to check whether it can redirect to the strNextpage you can check the value of the strLastPage. You can check whether the strLastPAGE is null or empty. If it is not null or empty you need to modify the sqlcommand.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 26, 2012 11:14 AM

All replies

  • User1320101480 posted

    Check for Null values using IsNull

    Friday, April 20, 2012 12:46 AM
  • User1325920427 posted

    hi, thanks for the reply, i change the code

    If String.IsNullOrEmpty(strLastPAGE) Then
                Response.Redirect(strNextpage)
    
    
    and the whole code:


    Private Function validateLastPage() As Boolean

            Dim strNextpage As String = "esurvey.default.aspx?userid=" & strUserID & "&surveyid=" & strSurveyID & "&culture=en-US&" & Request.QueryString("culture")
    
            strSQL = "SELECT LastPage FROM UserMark WHERE LoginID='" & strUserID & "'"
            strLastPAGE = oCommon.ExecuteSQL(strSQL)
    
            If String.IsNullOrEmpty(strLastPAGE) Then
                Response.Redirect(strNextpage)
                Return False
            Else
                strSQL = "SELECT LastPage FROM UserMark WHERE UserID='" & strUserID & "'"
                strLastPAGE = oCommon.getFieldValue(strSQL)
                Dim notCompletePage As String = strLastPAGE & "?userid=" & strUserID & "&surveyid=" & strSurveyID & "&culture=en-US&" & Request.QueryString("culture")
                Response.Redirect(notCompletePage)
                Return False
            End If
    
            Return True
    
        End Function


    still not work

    Friday, April 20, 2012 1:08 AM
  • User1046077057 posted

    Hi,

    What do you mean of doesn't work? If you want to check whether it can redirect to the strNextpage you can check the value of the strLastPage. You can check whether the strLastPAGE is null or empty. If it is not null or empty you need to modify the sqlcommand.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 26, 2012 11:14 AM