UpdatePanel中的按钮不会将我重定向到另一个页面

时间:2018-07-30 11:06:55

标签: asp.net

我有一个带有按钮的表单,该表单用于验证必填字段,然后如果可以通过验证,将我转到另一页。我已将AJAX与UpdatePanel一起使用,如果需要该字段,则该标签会显示一个标签。 问题是当我按下按钮并且验证正确时,它不会将我重定向到另一页。

<asp:UpdatePanel ID="upn_Data" runat="server" UpdateMode="Always">
<ContentTemplate>
<div class="row inp-row check-field">
    <label for="option" class=" ">Option1 :*</label>
        <div class="text-inp with-tooltip">&nbsp;
            <asp:DropDownList ID="ddlOption1" runat="server" AutoPostBack="true" onselectedindexchanged="ddlOption1_SelectedIndexChanged">
            </asp:DropDownList>&nbsp;
            <asp:Label ID="lblRequiredOption1" runat="server" Text="Obligatory field" visible="false" AutoPostBack="true"></asp:Label> 
        </div>
</div>
</ContentTemplate>
</asp:UpdatePanel>


<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
    <div id = "buttons" class ="buttons">
    <asp:Button ID="Button1" runat="server" Text = "Continue" class="continue-btn" onclick="Button1_Click"></asp:Button>
    </div>
</ContentTemplate>
</asp:UpdatePanel>

在服务器中:

protected void Button1_Click(object sender, EventArgs e)
{
    bool nextPage = true;

    if (ddlOption1.SelectedValue == "*")
    {
        lblRequiredOption1.Visible = true;
        nextPage = false;
    }

    if (nextPage == true) {
       Type cstype = this.GetType();
       String csName = "RedirectScript";
       String script = "window.parent.location = '../Paso2.html'";

       ClientScriptManager cs = Page.ClientScript;
       cs.RegisterClientScriptBlock(cstype, csName, script.ToString(), true);
    }
}

0 个答案:

没有答案