Monday, October 17, 2011

Accessing Server Controls Using JavaScript

Suppose you have a Web server control called TextBox in your Web page:

<asp:TextBox id="Test" Text="Sample" runat="server">
You can access this value in a couple ways using JavaScript:
  1. 
    document.getElementById('<%=Test.ClientID%>').value;
    
    ClientID - server control identifier generated by ASP.NET
    
  2. 
    document.forms[0]['Test'].value;
     
     
    Note: Copy - Paste from this site http://www.devx.com/tips/Tip/28332
    

No comments:

Post a Comment