?
Solved

Calling a javascript as an event handler for an asp.net server control

Posted on 2007-08-12
2
Medium Priority
?
2,673 Views
Last Modified: 2013-11-26
hi,
This is kind of strange to me.. may be im missing something here.. i have a asp.net textbox control, and i m trying to associate a javascript function to OnTextChange event, but its giving me a strange error.. but when i  associate the same javascript function with onKeyUp event ( which doesnt even shows as a valid event in asp.net) it works fine..

<asp:TextBox ID="TextBox2" runat="server" onKeyUp="foo();"></asp:TextBox>  (works fine, but validation warning)
<asp:TextBox ID="TextBox2" runat="server" OnTextChanged="foo();"></asp:TextBox> (doesnt work error : Invalid expression term ')'     )

any idea?
0
Comment
Question by:jyotishb
2 Comments
 
LVL 18

Accepted Solution

by:
tusharashah earned 1500 total points
ID: 19680653
OnTextChange is a ASP.Net server side event.. to call the change event at client side you'll need to use OnChange event of JavaScript..

<asp:TextBox ID="TextBox2" runat="server" OnChange="foo();"></asp:TextBox>

-tushar
0
 
LVL 9

Expert Comment

by:Chirag1211
ID: 19681803
Instead try the following code on codebehind file in the Page_Load() event:

TextBox2.Attributes.Add("OnTextChanged","foo();");

Also add the javascript function foo() on the aspx page in the script tag.

Regards,

Chirag Patel
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Loops Section Overview
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question