重定向到aspx中的另一个页面 [英] Redirecting to another page in aspx
本文介绍了重定向到aspx中的另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在进行一项调查,当用户选择保存按钮时,会显示另一个字段谢谢您完成调查。我希望在五秒钟后将其重定向到另一个页面。单击按钮时的代码如下所示:
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:
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
推荐答案
相应地修改代码。
Modify code accordingly.
<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.
string script = "<SCRIPT LANGUAGE='JavaScript'> ";
script += "redirection()";
script += "</SCRIPT>";
Page.RegisterClientScriptBlock("ClientScript", script);
这篇关于重定向到aspx中的另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文