Monday, March 12, 2012

How to clear text box values using javascript in C#?


Paste the following code in between
<head>
<script type="text/javascript">
function cleartextbox()
{
document.getElementById('<%=Texbox1.ClientID%').Value= ' ' ;
//if more than one textBox need to clear then
document.getElementById('<%=Texbox2.ClientID%').Value= ' ' ;
document.getElementById('<%=Texbox3.ClientID%').Value= ' ' ;
return false;
}
</script>
</head>

Call that function in body into appropriate textbox
<body>
<asp:Button ID="Button1" runat="server" Text="Button"  OnClientClick="return cleartextbox();">
</body>

No comments:

Post a Comment