Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
191
rated 0 times [  198] [ 7]  / answers: 1 / hits: 127197  / 15 Years ago, thu, april 9, 2009, 12:00:00

the problem I'm facing is this:




  • I have a textbox for a date range along side a calendar control.

  • When the user selects a date from the calendar, it fills that date into the textbox

  • When this happens I want to fire a javascript function, however, the 'onchange' event doesn't seem to happen.



I'd ideally like to be able to add the event as an attribute to the textbox, something like:



txtCreateDate.Attributes.Add(onchange, string.Format(JSfunction({0},'{1}');, arg1, arg2));


more info:
The date is entered into the textbox in c#. The calendar control has an eventhandler on the page. When a date is selected, the eventhandler puts the date into the textbox. I have tried setting the focus to the textbox at this point, then putting an onBlur attribute on the textbox, but the textbox never seems to get focus.



I suppose I could directly call the javascript function at this point doing ClientScript.RegisterClientScriptBlock or something like that, but that seems sloppy and never works like I want it to.


More From » textbox

 Answers
64

You're misinterpreting what the onchange event does when applied to a textarea. It won't fire until it loses focus or you hit enter. Why not fire the function from an onchange on the select that fills in the text area?



Check out here for more on the onchange event: w3schools


[#99724] Friday, April 3, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zoey

Total Points: 120
Total Questions: 103
Total Answers: 105

Location: Marshall Islands
Member since Mon, May 31, 2021
3 Years ago
;