JS in ASP.NET

S

Samuel Shulman

Hi all

<asp:TextBox ID="txtCarat" runat="server" TabIndex="38" Width="28px"
onkeypress="return NumericOnly(event);"></asp:TextBox>

I tried to code this line to filter the none numeric characters typed into
the textbox but it doesn't accepts it
What is the syntax for JavaScript?

thank you,
Samuel
 
M

Mark Rae

<asp:TextBox ID="txtCarat" runat="server" TabIndex="38" Width="28px"
onkeypress="return NumericOnly(event);"></asp:TextBox>

I tried to code this line to filter the none numeric characters typed into
the textbox but it doesn't accepts it

<asp:TextBox is a server-side control - the avboe try to run a server-side
method called OnKeyPress...
What is the syntax for JavaScript?

In your page's Page_Load event:

txtCarat.Attributes.Add("onKeyPress", "return NumericOnly(event);");
 
S

Samuel Shulman

Thank you

Mark Rae said:
<asp:TextBox is a server-side control - the avboe try to run a server-side
method called OnKeyPress...


In your page's Page_Load event:

txtCarat.Attributes.Add("onKeyPress", "return NumericOnly(event);");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top