how to get clientid in external js file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dhamodaran
    New Member
    • Mar 2015
    • 2

    how to get clientid in external js file

    I can't get the clientid when using as external js file. Please help how to resolve this issue.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    what clientid?

    Comment

    • dhamodaran
      New Member
      • Mar 2015
      • 2

      #3
      Inline JS:
      ==========
      Code:
      <script>
      function test()
      {
      var getValue = document.getElementById('<%=TextBox1.ClientID%>').value;
      
      alert(getValue);
      }
      </script>
      
      <asp:TextBox id="TextBox1" runat="server" />
      <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 ?
      Last edited by Dormilich; Mar 6 '15, 07:22 AM. Reason: please use code tags

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        the JavaScript code is created by ASP. if you move it externally, ASP can’t set the ID value needed.

        Comment

        Working...