gpt4 book ai didi

asp.net - 按钮单击在更新面板中不起作用

转载 作者:行者123 更新时间:2023-12-04 03:51:25 25 4
gpt4 key购买 nike

当我在“更新”面板中使用“按钮”时,它不会触发点击事件,但在更新面板之外,它可以工作。

这是代码

<asp:UpdatePanel ID="updatePanel2" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:Button ID="btnBlock" class="Button" Text="BlockCalls" runat="server"
onclick="btnBlock_Click" Enabled="True" Width="100px" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnBlock" />
</Triggers>
</asp:UpdatePanel>

按钮的代码是
protected void btnBlock_Click(object sender, EventArgs e)
{
CtiWS.CtiWS CtiWS1 = new CtiWS.CtiWS();
Response.Write("<script>alert('"+Convert.ToString(Session["BlockCalls"])+"')</script>");
if (btnBlock.Text == "BlockCalls")
{
btnBlock.Text = "UnBlockCalls";
CtiWS1.BlockCalls("", "", HttpContext.Current.Session["HOSTID"].ToString()); //server block calls
}
else
{
btnBlock.Text = "BlockCalls";
CtiWS1.BlockCalls("", "", HttpContext.Current.Session["HOSTID"].ToString()); //server unblock calls
}

}

最佳答案

试试这个

ChildrenAsTriggers设置为true并在EventName="Click"中添加asp:AsyncPostBackTrigger

<asp:UpdatePanel ID="updatePanel2" runat="server" UpdateMode="Conditional" 
ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Button ID="btnBlock" class="Button" Text="BlockCalls" runat="server"
onclick="btnBlock_Click" Enabled="True" Width="100px" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnBlock" EventName="Click"/>
</Triggers>
</asp:UpdatePanel>

关于asp.net - 按钮单击在更新面板中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25075538/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com