如题,添加完后怎么调用这个属性呢?

解决方案 »

  1.   

    textBox.Attribute.Add("onclick", javascript);
      

  2.   

    textbox服务器端应该没有这个属性
    不过客户端当然支持这个属性了
    <script>
    function hehe(param)
    {
      alert(param);
    }
    </script>
    TextBox1.Attributes.Add("onclick","hehe(this.value);");
      

  3.   

    也可以硬写<asp:TextBox ID='TextBox' runat="server" onclick="alert('hello')"></asp:TextBox>
      

  4.   

    我想单击textbox,另外一个lable可见TextBox1.Attributes.Add("onclick","lable1.visible=true")
    <asp:TextBox ID="TextBox1" runat="server" onclick="onclick")
    这样写有什么不对阿?
      

  5.   

    这样写:
    服务器端ID和客户端ID没弄清楚
    <script>
    function visibleLable()
    {
      var id = "<%=Lable1.ClientID%>";
      document.getElementById("id").visible=true;
    }
    </script>
    TextBox1.Attributes.Add("onclick","visibleLable();");
      

  6.   


    <asp:TextBox ID="TextBox" onkeyup="change()"  runat="server"></asp:TextBox>
            <div id='showDiv' style="display:none">
                <asp:Label ID='Label1' runat="server"></asp:Label>
            </div> <script language="javascript" type="text/javascript" >
    function change()
            {
                //找到TextBox并获得他的内容
                var value=document.getElementById('TextBox').value;
                var len=value.length;
                if(len==0)
                    document.getElementById('showDiv').style.display='none';
                else
                    document.getElementById('showDiv').style.display='';
            }
            </script>你看下 是你想要的效果么~
      

  7.   

    首先你要这样写
    1.cs后台,TextBox1.Attributes.Add("onclick","javascript:visibleLable();");
    2.aspx页面上面写一个js函数 
    function visibleLable()
    {
    document.all.label1.display = block;
    }
      

  8.   

    <asp:TextBox ID="TextBox" onClientClick="your JavaScript function"  runat="server"></asp:TextBox>
      

  9.   

    textBox.Attribute.Add("onclick", javascript);
    <asp:TextBox ID='TextBox' runat="server" onclick="javascript"></asp:TextBox>
      

  10.   


    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
         <script language="javascript" type="text/javascript" >
            function change()
            {
                //找到TextBox并获得他的内容
                var value=document.getElementById('TextBox').value;
                var len=value.length;
                if(len==0)
                    document.getElementById('showDiv').style.display='none';
                else
                    document.getElementById('showDiv').style.display='';
            }
            </script></head>
    <body>
        <form id="form1" runat="server">
               <asp:TextBox ID="TextBox" onkeyup="change()"  runat="server"></asp:TextBox>
            <div id='showDiv' style="display:none">
                <asp:Label ID='Label1' runat="server" Text="我是Label"></asp:Label>
            </div>    </form>
    </body>
    </html>