javascript獲得服務器端控件的ID

View Code
 1 <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
5 <head runat="server">
6 <title></title>
7 <%--
8 <script type="text/javascript">
9 function E() {
10 var ary = document.getElementById("<%=TextBox1.ClientID %>");
11 var b = ary.tagName;
12 alert(ary+""+b);
13 }
14 </script>--%>
15
16 </head>
17 <body>
18 <form id="form1" runat="server">
19 <div>
20 <asp:Button runat="server" ID="btn" Text="asd" />
21 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
22 <input type="button" onclick="E();" value="ssss" />
23 </div>
24 </form>
25 </body>
26 </html>

 不知道大家還有什麼好的方法不?

欢迎访问草根帮【https://www.caogenbang.top】 草根帮带你走向人生巅峰,迎娶白富美!!!
原文地址:https://www.cnblogs.com/koeltp/p/2305207.html