asp:按钮在第二次单击时不触发服务器函数

asp:button not firing server function on second click

提问人:Karthik Nagaraj 提问时间:6/2/2017 更新时间:6/2/2017 访问量:30

问:

我有一个asp:button:

<asp:Button runat="server" ID="btnschedule" Text="Schedule" OnClick="btnschedule_Click" CssClass="btn btn-default custom-button" />

单击按钮后,将调用以下函数:

protected void btnschedule_Click(object sender, EventArgs e)
    {
        if (txtcertcode.Text == "")
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), System.Guid.NewGuid().ToString(), "showTrainingScheduleModal('courseErr');", true);
        }
        else
        {
            foreach (ListItem item in chk_ModeList.Items)
            {
                if (item.Selected)
                {
                    pnlschedule.Visible = true;
                    ScriptManager.RegisterStartupScript(this, this.GetType(), System.Guid.NewGuid().ToString(), "showTrainingScheduleModal();", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), System.Guid.NewGuid().ToString(), "showTrainingScheduleModal('chkErr');", true);
                }
            }
            dt_sch.Clear();
            grdviewschedule_training.DataSource = null;
            grdviewschedule_training.DataBind();
        }
    }

在代码中

ScriptManager.RegisterStartupScript(this, this.GetType(), System.Guid.NewGuid().ToString(), "showTrainingScheduleModal('chkErr');", true);

JavaScript 函数正在打开引导模式

问题出在第一次单击引导模式打开时,但是当我关闭模式并再次单击按钮时,没有任何反应。

实际工作应该像每次单击按钮模式应该打开一样。

任何帮助都会得到赞赏。 提前致谢。

jquery asp.net user-controls bootstrap-modal aspbutton

评论

0赞 Udit Sharma 6/2/2017
你添加了ajax scriptManager吗?
0赞 Karthik Nagaraj 6/2/2017
我添加了一个 ScriptManager,但我不知道它是否是 AJAX。你可以在上面的代码中看到。ScriptManager.RegisterStartupScript(this, this.GetType(), System.Guid.NewGuid().ToString(), "showTrainingScheduleModal('chkErr');", true);
0赞 Udit Sharma 6/3/2017
可能是这是回发问题。.检查 ispostback true

答: 暂无答案