<script language="javascript" type="text/javascript">
$(document).ready(function() {
$("#TextBox1").click(function() { alert("bla bla bla bla bla") });
});
</script>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TabContainer runat="server" ActiveTabIndex="0">
<asp:开发者_JS百科TabPanel runat="server" HeaderText="Easd">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel runat="server" HeaderText="asdasd">
<ContentTemplate>
asd</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
i need TextBox1 access
I'm not sure what you mean by "I need access", but I'm assuming you mean your jQuery code isn't working.
The generated clientside ID for serverside controls is different than your designed markup. You need to update your jQuery code:
$("#<%#TextBox1.ClientID %>").click(function() { alert("bla bla bla bla bla"); });
This will dynamically insert the Client ID for the textbox, such that your jQuery selector will work.
Edit:
If you need value as you commented:
$("#<%#TextBox1.ClientID %>").click(function() { alert( $(this).val() ); });
I'm only calling the javascript function alert
and jquery event click
based on your example code. As another example, if you wanted to alert/popup the value of the textbox when the user focuses away from it:
$("#<%#TextBox1.ClientID %>").blur(function() { alert( $(this).val() ); });
Hope this helps...
Try This:
<script type="text/javascript">
$(document).ready(function(){
alert($("#<%#TextBox1.ClientID %>").val());
});
</script>
Link
精彩评论