• <legend id='zbm7X'><style id='zbm7X'><dir id='zbm7X'><q id='zbm7X'></q></dir></style></legend>

      <small id='zbm7X'></small><noframes id='zbm7X'>

    1. <i id='zbm7X'><tr id='zbm7X'><dt id='zbm7X'><q id='zbm7X'><span id='zbm7X'><b id='zbm7X'><form id='zbm7X'><ins id='zbm7X'></ins><ul id='zbm7X'></ul><sub id='zbm7X'></sub></form><legend id='zbm7X'></legend><bdo id='zbm7X'><pre id='zbm7X'><center id='zbm7X'></center></pre></bdo></b><th id='zbm7X'></th></span></q></dt></tr></i><div id='zbm7X'><tfoot id='zbm7X'></tfoot><dl id='zbm7X'><fieldset id='zbm7X'></fieldset></dl></div>

        <bdo id='zbm7X'></bdo><ul id='zbm7X'></ul>
        <tfoot id='zbm7X'></tfoot>

        动态(以编程方式)添加复选框和checkedchanged事件

        Dynamically (programatically) adding check boxes and checkedchanged events(动态(以编程方式)添加复选框和checkedchanged事件)
        <legend id='4QtWK'><style id='4QtWK'><dir id='4QtWK'><q id='4QtWK'></q></dir></style></legend>

        • <bdo id='4QtWK'></bdo><ul id='4QtWK'></ul>
          <tfoot id='4QtWK'></tfoot>

              <tbody id='4QtWK'></tbody>
              <i id='4QtWK'><tr id='4QtWK'><dt id='4QtWK'><q id='4QtWK'><span id='4QtWK'><b id='4QtWK'><form id='4QtWK'><ins id='4QtWK'></ins><ul id='4QtWK'></ul><sub id='4QtWK'></sub></form><legend id='4QtWK'></legend><bdo id='4QtWK'><pre id='4QtWK'><center id='4QtWK'></center></pre></bdo></b><th id='4QtWK'></th></span></q></dt></tr></i><div id='4QtWK'><tfoot id='4QtWK'></tfoot><dl id='4QtWK'><fieldset id='4QtWK'></fieldset></dl></div>
                • <small id='4QtWK'></small><noframes id='4QtWK'>

                  本文介绍了动态(以编程方式)添加复选框和checkedchanged事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在以编程方式添加几个复选框和事件处理程序时遇到了一点问题.复选框看起来都很好,但单击时它们不做任何事情.有谁知道我做错了什么?

                  I am having a bit of a problem adding a few check boxes and an event handler programatically. The check boxes all appear fine, but they don't do anything when clicked. Does anyone have any idea what I am doing wrong?

                  foreach (Statement i in theseStatements)
                  {
                      box = new CheckBox();
                      box.Text = i.StatementText;
                      box.AutoPostBack = true;
                      box.CheckedChanged += new EventHandler(this.CheckedChange);
                      PlaceHolder.Controls.Add(box);
                  }
                  
                  protected void CheckedChange(object sender, EventArgs e) 
                  {
                      CheckBox x = (CheckBox)sender;
                      Instructions.Text = "change";            
                      WorkPlaceHazardsBox.Text += x.Text;
                  } 
                  

                  推荐答案

                  你应该做到以下几点:

                  1. 为您在 foreach 循环中创建的每个 CheckBox 实例设置 ID 属性.
                  2. 对于 PostBacks,请确保已创建 CheckBox,并在页面生命周期的某个时间点附加 CheckedChanged 事件处理程序在引发控件事件之前
                  1. Set the ID property for each instance of CheckBox you create in your foreach loop.
                  2. For PostBacks, ensure that your CheckBoxes are created and CheckedChanged event handler is attached at some point of the page life-cycle before control events are raised

                  这篇关于动态(以编程方式)添加复选框和checkedchanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  Using entity Framework with .NET Core and DB2(将实体框架与 .NET Core 和 DB2 结合使用)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)

                    <tfoot id='fiiQx'></tfoot>

                  1. <i id='fiiQx'><tr id='fiiQx'><dt id='fiiQx'><q id='fiiQx'><span id='fiiQx'><b id='fiiQx'><form id='fiiQx'><ins id='fiiQx'></ins><ul id='fiiQx'></ul><sub id='fiiQx'></sub></form><legend id='fiiQx'></legend><bdo id='fiiQx'><pre id='fiiQx'><center id='fiiQx'></center></pre></bdo></b><th id='fiiQx'></th></span></q></dt></tr></i><div id='fiiQx'><tfoot id='fiiQx'></tfoot><dl id='fiiQx'><fieldset id='fiiQx'></fieldset></dl></div>

                    1. <small id='fiiQx'></small><noframes id='fiiQx'>

                            <tbody id='fiiQx'></tbody>
                          <legend id='fiiQx'><style id='fiiQx'><dir id='fiiQx'><q id='fiiQx'></q></dir></style></legend>
                            <bdo id='fiiQx'></bdo><ul id='fiiQx'></ul>