asp tags not visible by XHTML DOM structure?

I am using ASP.NET. I have a text box with an image adjacent to it. When this image is clicked on a model box pops up with a pretty calender. When the user clicks on a date the model box closes and the text box now contains the date – this all works, I have implemented it several times on several web pages for consistency.

The problem comes with the Text Changed event of the text box, it doesn’t fire! It doesn’t fire at all until a post-back occurs! This is a problem for me because I want to add seven days to the date that has just been populated in the text box and display the new date in a label underneath the text box, as soon as the date is visable - a simple thing I want to do, so you would think!?

I have thought about the problem and and after many debugging sessions trying to figure it out I have decided to use Java-Script as you can specify the ‘OnChange’ event for a text box which solves the problem, well half solves it.

I have managed to get the event to work as it displays an alert box on text changed, hurrah! But I have spent several hours trying to use the getElementById and getAttribute functions of the DOM to get the text property of the text box and put the contents in the text property of the label – with no luck.

I have downloaded a java-script debugger that works in Fire-fox and it tells me that the getElementById returns no value. I tried the same code with a <p> instead of a <asp:TextBox> and it works, therefore the problem must be: the asp tags do not work/are not readable with the XHTML DOM structure of the page. Bugger. I have spent an hour browsing forums + google for answers with no luck.

I am annoyed that I cant fix this seemingly simple problem that the client needs. It is past 5pm on a Friday, i am calling it a week.

Any help appreciated.

3 Responses to “asp tags not visible by XHTML DOM structure?”


  1. 1 Joel November 3, 2007 at 12:22 pm

    If you are trying to get the “onchange” event to fire on the input element, it will only fire when an end user alters the content (JavaScript won’t trigger the event).

    Keep in mind, that once the page renders, your ASP tags are no longer accessible to the browser.

    Finally, what you want to do, is have your click on the image call your calendar function, passing in a callback function to call when a date is picked. In your callback function, get your date, add 7 days, and populate the input box.

  2. 2 rabywhyte November 3, 2007 at 1:49 pm

    When you say callBack function, I take it you mean the JS function that opens the calendar and returns the date to the input box? So before returning the value does the necessary calculation and input here? I never thought of that, thank you for the advise, I will give it a go (:

    “Keep in mind, that once the page renders, your ASP tags are no longer accessible to the browser.”

    I realised this after posting on my blog, that server side tags will not be seen client side, therefore the JavaScript won’t be able to see them.

    Thanks for the advice, much appreciated

  3. 3 rabywhyte November 5, 2007 at 4:41 pm

    I have solved this problem today with a fresh mind this Monday morning woot! (:

    I cheated, instead of bothering with the text change event on both the server and client side I just manipulated and showed the date before the function returned the date to the original text box.

    Thanks for the push in the right direction Joel (:


Leave a Reply