Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

How to access asp:TextBox with runat=server attribute in javascript

For example you have a textbox which has a default value, and you want to clear that value when the user click on the textbox:


<asp:TextBox ID="txtBox" runat="server" onclick="clear()" Text="Enter Keyword" />

<script type="text/javascript">
        function clear() {
            document.getElementById("<%=txtBox.ClientID %>").value = "";
        }
</script>     
How to access asp:TextBox with runat=server attribute in javascript How to access asp:TextBox with runat=server attribute in javascript Reviewed by Edward Legaspi on Wednesday, January 19, 2011 Rating: 5

No comments:

Powered by Blogger.