ClientID获取服务端控件,客户端id的方法

ClientID获取服务端控件,客户端id的方法,第1张

ClientID 获取服务端控件,客户端id的方法
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication5.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="jquery-2.1.0-beta3.js"></script>
<script type="text/javascript">
$(function () {
$("#btn").click(function () { alert($("#"+"<%=TextBox1.ClientID %>").val());
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input type="button" value="点击" id="btn" />
</div>
</form>
</body>
</html>

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/587453.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存