When I use Button inside Update panel it doesnot fire click event but outside the update panel it works.
here is the code
当我在更新面板中使用按钮时,它不会触发单击事件,而是在更新面板之外工作。这是代码
<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>
code for button is
代码按钮
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
}
}
1 个解决方案
#1
9
Try this
试试这个
set ChildrenAsTriggers
to true
and add EventName="Click"
in asp:AsyncPostBackTrigger
将ChildrenAsTriggers设置为true,并在asp:AsyncPostBackTrigger中添加EventName="Click"
<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>
#1
9
Try this
试试这个
set ChildrenAsTriggers
to true
and add EventName="Click"
in asp:AsyncPostBackTrigger
将ChildrenAsTriggers设置为true,并在asp:AsyncPostBackTrigger中添加EventName="Click"
<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>