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
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 Qi Wu - MSFT on May 02, 2012 02:40 AM
aznimah
0 Points
6 Posts
help on redirect to the last page update in database
Apr 20, 2012 04:39 AM|LINK
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
--> this will redirect page to the last page update in database
but when i change the code
--> 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 Functionreally need help on urgently . thank you so much
nijhawan.sau...
All-Star
16430 Points
3173 Posts
Re: help on redirect to the last page update in database
Apr 20, 2012 04:46 AM|LINK
Check for Null values using IsNull
aznimah
0 Points
6 Posts
Re: help on redirect to the last page update in database
Apr 20, 2012 05:08 AM|LINK
hi, thanks for the reply, i change the code
If String.IsNullOrEmpty(strLastPAGE) Then Response.Redirect(strNextpage)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 Functionstill not work
Richey
Contributor
3816 Points
431 Posts
Re: help on redirect to the last page update in database
Apr 26, 2012 03:14 PM|LINK
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.