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>     

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post
NERV Open Source

Building production Spring Boot systems?

Explore NERV — open-source Java libraries for audit trails, persistence, exception handling, and reliable event-driven architecture.

Explore NERV on GitHub →