Can I use OnTextChanged in JavaScript for TextBox


    Sponsored Links


  • 1. Textbox Web Control
    Hello, I have a SQL Server table which has several columns that are of type varchar. I have bound textboxes for this table on a Web form. The form is used for data entry. Question: How do I get rid of the trailing blanks on the control? The blanks are annoying because you can't insert characters because the maxlength has been reached. Right now I have to delete the trailing blanks before I can successfully edit the field. This seems like a trivial thing to me, but I can't figure out how to do it. Thanks
  • 2. Finding an index in a dataset and setting SelectedIndex on dropdownlist
    Hi all, I have a dataset bound to a dropdownlist and I'm trying to get the dropdownlist to start off with a default value selected (not the first value). Is there any way that I can retrieve the index of the item I want from the dataset and use this to set the SelectedIndex of the dropdownlist? I've tried creating a dataview from the dataset and sorting it and then using the return value of DataView.Find() method to set the index but it doesn't seem to set the index correctly (probably because it is now sorted?). Is the only way to iterate through the dataset until I find the row I want? Thanks Rene
  • 3. How do you Highlight text within asp:textbox?
    I have a large asp:textbox. I want to implement a "Find" function. It would be best if this can be done with a JavaScript (or some other method) totally at the client site without the server's knowledge How do I a) Highlight text within a textbox b) Determine which text is highlighted (possibly by the user) within a textbox?
  • 4. Call a control's postback in client script
    Hi, I have a table, where i want each cell to be clickable in its entirety to do a postback. Each cell shows a product special, with description, mfgpn, price, and a product image. I made the image an asp:imagebutton, which when clicked, will do a postback to load the product specsheet. I want the entire cell to do this onclick. What i tried was: <script> function clickBack<%=prodnum%>(){ __dopostback('<%=imgImage.ClientID%>',''); } </script> <table onclick="clickBack<%=prodnum%>()"> <tr><td> other contents here <asp:imagebutton id=imgImage runat=server></asp:imagebutton> </td></tr> </table> The code works and does the postback, but it doesnt actually call the OnClick handler for imgImage. Thanks in advance, - Eidolon.
  • 5. Firing datagrid dropdownlist on selection change
    I have a datagrid with a template that has several dropdownlists when in edit mode. I need an event handler for the dropdownlist so on a new selection several other dropdownlists are updated with related data. I have written code to do just this on the itemCreated event of the datagrid, but need to execute this same code on a selection change in the dropdownlist. How do I do this in code behind? How do I reference the datagrid control and capture the event Thank you Troy

Can I use OnTextChanged in JavaScript for TextBox

Postby Leo » Thu, 20 Nov 2003 03:25:39 GMT

I have my textbox control, I want to fire an event for 
TextChanged, how can I do this?

Can I use OnTextChanged in JavaScript for TextBox

Postby Jon Paugh » Thu, 20 Nov 2003 05:32:52 GMT

try this:
set the "OnChange" attribute for your server side control 
to your js function in the onload event of your page's 


Similar Threads:

1.JavaScript for OnTextChanged event.


I have created a web-based file manager. Now I'd like to watch a folder for 
changes, and when a change occurs I'd like to refresh my page.
Okay. So I have created a FileSystemWatcher set on the folder I need to 
watch. It works fine. The problem occurs when I need to trigger an automatic 
So I added two handlers - OnChanged and OnRename, in the same class as my 

In the handlers I tried to say Response.redirect(mypage) to force the 
refresh, but the error I got was: "Cannot redirect after HTTP headers have 
been sent."

So I tried to change the text of some textbox instead
<asp:textbox id="txtFileSystemWatcher" 
OnTextChanged="javascript:RefreshPage();" Visible=true  Width=500 

with this handler:
Private Sub OnChanged(ByVal source As Object, ByVal e As 
    txtFileSystemWatcher.Text = "FileSystemWatcher: " & "File: " & 
e.FullPath & " " & e.ChangeType
End Sub

and add an OnTextChanged client-side event-handler which looks like this:

function RefreshPage() {
    __doPostBack('txtFileSystemWatcher', '');

which would force the refresh. However, now I have the following error:
BC30456: 'javascript' is not a member of 'ASP.BrowseFiles_aspx'.

So I changed the HTML to
<asp:textbox id="txtFileSystemWatcher" OnTextChanged="RefreshPage()" 
Visible=true  Width=500 Runat=server></asp:textbox>
and now, sure enough, I get
BC30456: 'RefreshPage' is not a member of 'ASP.BrowseFiles_aspx'.

I also tried in OnLoad of the page to register the event with
txtFileSystemWatcher.Attributes.Add("OnTextChanged", "RefreshPage()")

but it still does not work.

What am I missing here, please ?

Thank you, Alex 

2.Accessing Textbox inside a Template column using javascript

I am having a datagrid with a template column. Inside the template column I
have a textbox and an image button. On click of the image button, I want to
call a javascript function, where the textbox value has to be taken.

Since the textbox is inside the datagrid, how can I access the Textbox in a
javascript function?

what is happening now is that if I give document.frmname.textboxname then it
won't recognise because for textboxes in each row of the datagrid is
internally given a different name.

can you please assist me regarding this?

Thanks & Regards,

3.How can i change de cssclass of a textbox in runtime using javascript

I need to change de css of an textbox control.
So, on mouseover event, the class will be one, and on mouseout event it will 
be another.
Something like:


How can i do that?
Somebody have any idea?


Fernando Lopes 

4.get Textbox Value in datagrid using JavaScript

Hi, All:

I have a datagrid that embedded 3 textbox using TemplateColumn. When
the user key in value in the first textbox, I need to check to see if
this value is between the the values in other 2 textboxes. I know I can
postback to server side and using datagrid findcontrol to get values of
these 3 textboxes and compare them. But it kind of combersome cause
every change in textbox 1 I need send back to server.

My question is how can I get other 2 textboxes values in the same row
of textbox1 using Javascript? I am using onChange function for
textbox1. Is it doable? any example?

Thanks a lot
-Rockdale can I used javascript for chaging values in TextBox

6. link textboxes in gridview EditItem template using javascript

7. Dynamically generate textboxes using javascript

8. How to get OuterHtml in a TextBox using Javascript

Return to ASP.NET


Who is online

Users browsing this forum: No registered users and 93 guest