当前位置: 代码迷 >> ASP.NET >> ASP.NET 在前台如何获取后台自动生成的button
  详细解决方案

ASP.NET 在前台如何获取后台自动生成的button

热度:2713   发布时间:2013-02-25 00:00:00.0
ASP.NET 在前台怎么获取后台自动生成的button
后台代码:
C# code
            Button btn = new Button();            this.div2.Controls.Add(btn);            btn.Text = ds.Tables[0].Rows[i][0].ToString();            btn.Style.Add("border", "white 2px solid");            btn.Attributes.Add("onclick", "<script>btn_onclick(this)</script>");



我在后台自动生成了几个button,现在想给他产生客户端点击事件,我要在前台javascript代码中怎么获取到这些控件呢?

谢谢大家!!

------解决方案--------------------------------------------------------
HTML code
    <form id="form1" runat="server">    <div id="divContainer" runat="server">    </div>    <script type="text/javascript">        function test(id) {            alert(id);        }    </script>    </form>
------解决方案--------------------------------------------------------
探讨
引用:

HTML code
<form id="form1" runat="server">
<div id="divContainer" runat="server">
</div>
<script type="text/javascript">
function test(id) {
alert(id);
}……
如果是生成多个button……
  相关解决方案