- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
更清晰的解释这里是我在 .asp
上的代码文件:
<asp:UpdatePanel ID="updPnlTabs" runat="server" >
<Triggers>
<asp:PostBackTrigger ControlID="btnSave" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlCheckList" runat="server" style="margin-bottom: 10px;" CssClass="listingDummyTab">
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
.cs
代码,我像这样动态地为 pnlCheckList 创建了复选框:
CheckBox chkModuleID = new CheckBox();
chkModuleID.ID = drNew[def.ID].ToString();
chkModuleID.AutoPostBack = true;
chkModuleID.CheckedChanged += new EventHandler(chkID_OnRow_Check);
pnlCheckList.Controls.Add(chkModuleID);
UpdatePanel
的内容.请注意,动态创建的复选框的 EventHandler 正在触发,但不在 UpdatePanel 内。
ID
的动态创建的
Controls
在
<Triggers>
的
UpdatePanel
?
最佳答案
无法将动态(或以编程方式创建的)控件添加到标记中,因此,您必须使用 ScriptManager
注册控件。创建之后。
每 AsyncPostBackTrigger
documentation ,添加一个 AsyncPostBackTrigger
不支持以编程方式控制:
To programmatically register a postback control, use the
RegisterAsyncPostBackControl
method of theScriptManager
control. Then call the Update method of theUpdatePanel
control when the control posts back.
// original code
CheckBox chkModuleID = new CheckBox();
chkModuleID.ID = drNew[def.ID].ToString();
chkModuleID.AutoPostBack = true;
chkModuleID.CheckedChanged += new EventHandler(chkID_OnRow_Check);
pnlCheckList.Controls.Add(chkModuleID);
// register the control to cause asynchronous postbacks
ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(chkModuleID);
chkID_OnRow_Check
回调/事件处理函数,确保你调用
UpdatePanel1.Update()
.
// One possibility is this - assuming you don't require a consistent ID
chkModuleID.ID = String.Format("{0}-{1}", drNew[def.ID].ToString(), Guid.NewGuid().ToString("N"));
关于c# - 将 PostBackTrigger 和 AsyncPostBackTriggers 添加到 UpdatePanel 以使用 checkChanged EventHandler 动态生成复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14742426/
我一直在 sencha 论坛以及堆栈溢出中寻找解决方案。我无法找到这个问题的正确解决方案。我想在该行中检查列的 checkchange 事件上编辑网格中某行的特定单元格。 以下是代码-
我的 checkColumn 的 checkchange 监听器不起作用。任何想法为什么不呢? var checked = new Ext.grid.CheckColumn({ header: '
我有一个扩展标准 asp.net gridview 控件的自定义 gridview 控件。 gridview 的第一列由动态创建的复选框字段组成。我在 OnRowDataBound 事件期间为复选框的
我的应用程序中有 16 个单选按钮..我必须根据选择的变量设置一个变量..我已经为此生成了一些非常丑陋的代码.. private void Foo_CheckedChanged(object send
我有一个包含复选框和文本框的用户控件: 在 Page_Load 上,我将其中的几个动态添加到页面上的面板中: //loop through the results from DB foreac
在我的项目中的一个页面中,我正在创建一个复选框,并在复选框检查更改时执行一些服务器端任务。我想要的是在转到后面的代码之前显示一条确认消息。 如果我调用 Javascript 函数,它会返回 true/
我在互联网上搜索如何在 RadioGroup 上执行新的很酷的 android 数据绑定(bind),但我没有找到一篇关于它的博客文章。 这是一个简单的场景,基于所选的单选按钮,我想使用 androi
请告诉我在 CheckBox 的 CheckChanged 事件中使用参数 e 作为 System.EventArgs 最佳答案 你可以忽略这个。 所有事件都具有相同的签名:void handler(
我有一个 TreePanel。树中的每个节点都有一个 ID。单击一个按钮,我想触发节点 2.1 的 checkchange 事件(如下图所示)。如何在单击按钮时使用其 ID 为节点触发 checkch
更清晰的解释这里是我在 .asp 上的代码文件: 在我的 .cs代码,我像这样动态地为 pnlCheckList 创建了复选框: CheckB
我是一名优秀的程序员,十分优秀!