how to call javascipt function asp.net controls

Posted by Prince5 under JavaScript on 2/15/2009 | Views : 6376 | Status : [Member] | Replies : 1
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="javascript2.aspx.cs" Inherits="javascript2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function NumericOnly()
{

if (event.keyCode >= 48 && event.keyCode <= 57) event.returnValue = true;
else
event.returnValue=false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>

now i have javascript function. how to call this function in asp.net controls



thank you




Responses

Posted by: Raja on: 2/15/2009 [Member] Starter

Up
0
Down
Just write in the same way as you write for the html controls.

like

<asp:TextBox ID="txtT" runat="server" onchange="NumericOnly()"></asp:TextBox>


Instead of onchange, you use onclick, ondblclick etc.

Thanks



Regards,
Raja, USA

Prince5, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response