JavaScript抓取asp.net值

JavaScript抓取asp.net的值用的还是比较多的,但有些写法还是不推荐的,这里写出来。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="javascript获取控件值.aspx.cs"
Inherits="asp.net课堂演示._1111111111111" %>
<!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 type="text/javascript">
function Test() {
alert(document.getElementById("<%=txt1.ClientID %>").value);
alert(document.getElementById("txt1").value);//此方法不推荐
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt1" runat="server" Text="Test"></asp:TextBox>
<asp:Button ID="btn1" runat="server" Text="Test" _disibledevent=>
</div>
</form>
</body>
</html>
Tags: 

延伸阅读

最新评论

发表评论