给asp控件添加js方法

来源:互联网 发布:运用思维导图学编程 编辑:程序博客网 时间:2024/05/01 02:54

学习笔记:.net/  2007-10-02

给Web控件添加js可以调用的方法

default.aspx.cs

     protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
                       this.TypeList1.Attributes.Add("onchange", "Type2();");  
            
        }

  }

-------------------------------------------------------------------------------------------------------------------------------

default.aspx

<script language="javascript" type="text/javascript">            
            function Type2()
            { 
                var a = document.getElementById('<%=TypeList1.ClientID%>').value;//获取TypeList1控件的值
                alert(a);           
            }

    </script>-

原创粉丝点击