js...

    技术2024-11-21  4

    <script src="prototype.js" type="text/javascript"></script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title>Untitled Page</title>    <script>    function ControlDisPlay()    {    var dd = $F('userName');// 注意用法 Literal的各种mode    alert("haha   "+dd+"");//      var seleectAll= $("<%=SelectAll.ClientID %>").checked;    var seleectAll= document.getElementById('SelectAll').checked;    var   tables=document.getElementsByTagName( 'input');     var len = tables.length;    if(seleectAll)    {      for(var i=0; i<len;i++)       {      if((tables[i].type=="checkbox"))            {            tables[i].checked = true;             Controltr();                   }       }    }     else    {     for(var i=0; i<len;i++)          {            if((tables[i].type=="checkbox"))            {            tables[i].checked = false;           Controltr();                    }          }    }     }       function Controltr()    {     var en = $("<%=caoyougang.ClientID %>").checked;     var ens = $("<%=tr1.ClientID %>");       ens.disabled=en;             var en1 = $("<%=yyy.ClientID %>").checked;     var ens1 = $("<%=Text1.ClientID %>");       ens1.disabled=en1;            var en2 = $("<%=zzz.ClientID %>").checked;     var ens2 = $("<%=Text3.ClientID %>");       ens2.disabled=en2;      }   function test3()     {       alert( $F('userName') );     }        </script></head><body>    <form id="form1" runat="server">    <div>    <table border="1" width="600" cellpadding="1" cellspacing="1">                 <tr><td>                    Mode</td><td>                     效果</td></tr>                 <tr><td>                         PassThrough</td><td>                         <asp:Literal ID="Literal1" runat="server"  Mode="PassThrough" Text="<xyz>http://blog.csdn.net/zhoufoxcn</xyz>"></asp:Literal></td></tr>                 <tr><td>                         Encode</td><td>                         <asp:Literal ID="Literal2" runat="server" Mode="Encode" Text="<xyz>http://blog.csdn.net/zhoufoxcn</xyz>"></asp:Literal></td></tr>                 <tr><td>                         Transform</td><td>                         <asp:Literal ID="Literal3" runat="server" Text="<xyz>http://blog.csdn.net/zhoufoxcn</xyz>"></asp:Literal></td></tr>                         <tr>                        <td>                        <input type="checkbox" id="SelectAll"  runat="server" οnclick="ControlDisPlay()" />                        </td>                        </tr>                          <tr >                        <td>                        <input type="checkbox"  id="caoyougang" name="xxx"   οnclick="Controltr()"   runat="server" Text="Select All"/>                        <input id="tr1"    type="text" name="xxx" runat="server"/>                        </td>                        </tr>                          <tr  id="tr2" runat="server">                        <td>                        <input type="checkbox" id="yyy" name="Check2" οnclick="Controltr()"   runat="server"  Text="Select All"/>                        <input id="Text1"  type="text" name="yyy" runat="server"/>                        </td>                        </tr>                          <tr  id="tr3" runat="server">                        <td>                        <input type="checkbox" id="zzz" name="Check3"    οnclick="Controltr()"    runat="server" Text="Select All"/>                        <input id="Text3"   type="text" name="zzz" runat="server"/>                        </td>                        </tr>                        <tr>                        </tr>                        <tr>                        <td>                        <input type="text" id="userName" value="Joe Doe"><br><input type="button" value=Test3 οnclick="test3();"><br>                         </td>                        </tr>                       <tr>                       </tr>                </table>

        </div>

     

    另一种方法。。

     

      protected void Register()    {       StringBuilder bu = new StringBuilder();     bu.AppendLine(@"function Controltr() {");        bu.AppendLine("var en = $('"+caoyougang.ClientID+"').checked;");     bu.AppendLine("var ens = $('"+tr1.ClientID+"')");       bu.AppendLine("ens.disabled=en;");          bu.AppendLine("var en1 = $('"+yyy.ClientID+"').checked;");     bu.AppendLine("var ens1 = $('"+Text1.ClientID +"')");       bu.AppendLine("ens1.disabled=en1");            bu.AppendLine("var en2 = $('"+zzz.ClientID +"').checked");     bu.AppendLine("var ens2 = $('"+Text3.ClientID +"')");       bu.AppendLine("ens2.disabled=en2; }");     ScriptManager.RegisterClientScriptBlock(this, GetType(), "dd", bu.ToString(), true);    }

     

    最新回复(0)