By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,860 Members | 1,287 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,860 IT Pros & Developers. It's quick & easy.

how to get clientid in external js file

P: 2
I can't get the clientid when using as external js file. Please help how to resolve this issue.
Mar 5 '15 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 5K+
P: 8,639
what clientid?
Mar 5 '15 #2

P: 2
Inline JS:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function test()
  3. {
  4. var getValue = document.getElementById('<%=TextBox1.ClientID%>').value;
  6. alert(getValue);
  7. }
  8. </script>
  10. <asp:TextBox id="TextBox1" runat="server" />
  11. <asp:Button value="submit" id="btnSubmit" onclientClick="test();" /> 
While button click event i can get the Textbox values. When i move into separate js file i can't get TextBox value.

How to do it ?
Mar 6 '15 #3

Expert Mod 5K+
P: 8,639
the JavaScript code is created by ASP. if you move it externally, ASP can’t set the ID value needed.
Mar 6 '15 #4

Post your reply

Sign in to post your reply or Sign up for a free account.