我现在有点困惑。让我解释一下:为什么我没有看到为服务器端控件生成的ID?
我见过有人在讨论在asp.net(3.5)的页面中添加一个按钮或其他控件,并且控件呈现它时会更改该控件的ID,例如。 Button1的成为Button1_somethingsomething以防止它们使用jQuery,他们最终采用什么是<%controlId.ClientId %>
所以我做了一个小测试
1. I added a button on the page:
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
<div>
2. Then I added a JavaScript and jQuery:
<script type="text/javascript">
$(document).ready(function() {
$("#Button1").click(function() {
alert("Hello world!");
});
});
</script>
3. The generated html is this:
<div>
<input type="submit" name="Button1" value="Button" id="Button1" />
<div>
现在这样的东西,我没有看到ASP.NET(ASP。净3.5)改变ID。为什么我看到不同的行为?
Btw。这在我点击按钮时起作用!
谢谢。