在后台如何动态添加html控件的事件,或者控制html控件的事件

解决方案 »

  1.   

    后:
    this.Response.Write("<INPUT style='Z-INDEX: 101; LEFT: 296px; POSITION: absolute; TOP: 128px' type='button' value='Button' onclick='wzl()'>");

    function wzl()
    {
    alert('fdsfdsf');
    }
      

  2.   

    我的问题是动态添加html控件的事件,或者控制html控件的事件
    而不是动态添加控件。
      

  3.   


    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!IsPostBack)
    {
    this.HyperLink5.Attributes.Add("onclick","exitLogin();"); }
    }
      

  4.   

    this.HyperLink5.Attributes.Add("onclick","exitLogin();")
    就用Attributes.Add()
    里面两个参数,一个是key,一个是Value
      

  5.   

    加客户端事件使用
    attachEvent() / addEventListener()
    加服务端事件使用
    +=/-=ps:服务端是取不到单纯的html,并响应其事件的,除非runat="server"
      

  6.   

    <input type=button id=btn>
    <script>
    document.all['btn'].onclick = function xx()}{alert('动态事件')!};
    </script>也可以用AttachEvent