<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<script type="text/javascript" language="javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
var elem = args.get_postBackElement();
ActivateAlertDiv('visible', 'AlertDiv', elem.value + ' processing...');
}
function EndRequestHandler(sender, args) {
ActivateAlertDiv('hidden', 'AlertDiv', '');
}
function ActivateAlertDiv(visstring, elem, msg) {
var adiv = $get(elem);
adiv.style.visibility = visstring;
adiv.innerHTML = msg;
}
</script>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="Server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" GroupingText="Update Panel">
Last update:
<%= DateTime.Now.ToString()%>.
<br />
<asp:CheckBox runat="server" Text="Checkbox1" />
<asp:Button runat="server" ID="Button1" Text="Process 1" OnClick="ProcessClick_Handler" />
<asp:Button runat="server" ID="Button2" Text="Process 2" OnClick="ProcessClick_Handler" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<div id="AlertDiv" class="AlertStyle">
</div>
</div>
</form>
Button1和Button2触发了beginRequest事件,但Checkbox1没有。
答案 0 :(得分:0)
您需要在复选框中将AutoPostback设置为true:
<asp:CheckBox ID="CheckBox1" runat="server" Text="Checkbox1" AutoPostBack="true"/>
答案 1 :(得分:0)
您必须将CheckBox的AutoPostBack属性设置为True
答案 2 :(得分:0)
添加AutoPostBack="true"
并添加活动oncheckedchanged="Checkbox1_CheckedChanged1"
<asp:CheckBox runat="server" Text="Checkbox1" AutoPostBack="true"
oncheckedchanged="Checkbox1_CheckedChanged1"/>