Click here to Skip to main content
16,020,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im doing a survey, and when the users oress the save button they are shown another field "Thankyou for fullfilling the survey" And I want that thay after five seconds to be redirected to another page. the code when the button is clicked is this code as shown below:
VB
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        CheckAllAnswersAreAnswered()
        If check = True Then
            Exit Sub
        Else
            For Each item As DataListItem In DataList1.Items
                If item.ItemType = ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Then
                    Dim questionid As Integer
                    Dim choiceid As Integer = 0
                    Dim choicetext As String = ""

                    questionid = CType(item.FindControl("Label3"), Label).Text
                    Dim anstype As HiddenField = item.FindControl("HiddenField1")
                    Select Case anstype.Value
                        Case "S"
                            Dim rbl As RadioButtonList = item.FindControl("RadioButtonList1")
                            'if rbl.Items.
                            If rbl.SelectedValue = Nothing Then
                                choiceid = Nothing
                            Else
                                choiceid = rbl.SelectedValue
                            End If
                            SaveAnswer(questionid, choiceid, "")

                        Case "M"
                            Dim cbl As CheckBoxList = item.FindControl("CheckBoxList1")
                            countChk = cbl.Items.Count
                            For i As Integer = 0 To cbl.Items.Count - 1
                                If cbl.Items(i).Selected Then
                                    choiceid = cbl.Items(i).Value
                                    SaveAnswer(questionid, choiceid, "")
                                Else
                                    count = count + 1
                                End If

                            Next
                        Case "T"
                            Dim txt As TextBox = item.FindControl("TextBox1")
                            choicetext = txt.Text
                            SaveAnswer(questionid, 0, choicetext)
                    End Select
                End If
                If count >= countChk And count > 0 Then
                    Dim myStringVariable As String = String.Empty
                    myStringVariable = "Потребно е да одговорите на сите прашања!"
                    ClientScript.RegisterStartupScript(Me.GetType(), "myalert", "alert('" + myStringVariable + "');", True)
                    Exit Sub
                End If
                count = 0
            Next
            DataList1.Visible = False
            Label5.Text = "Thankyou for fullfilling the survey!"
        End If
    End Sub
Posted
Updated 21-May-13 21:20pm
v2

1 solution

Modify code accordingly.
C#
<script type="text/javascript">
   function redirection()
   {
        setTimeout("top.location.href = 'your url'",5000);
   }
</script>


call this function from code behind wherever you want user to be alerted and redirected.


XML
string script = "<SCRIPT LANGUAGE='JavaScript'> ";
script += "redirection()";
script += "</SCRIPT>";
Page.RegisterClientScriptBlock("ClientScript", script);
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900