.net mix with javascript

liunx

Guest
A little difficult to explain but I'll do my best.

I have this javascript calendar which gets the current month based upon a value in 2 boxes (1 box for the month and 1 box for the year). Both boxes are filled from server side. The values placed into the text boxes match the same structure as that in the javascript calendar.

I was thinking I could just do a

currentyear = document.getElementById("yearBox");
currentyear = document.getElementById("monthBox");
to get the value from the text boxes with ID "yearBox" and monthbox based upon what is fed into them from when the server side script runs.

This for some reason doesn't happen. The text boxes have the values in them but the document.getElementById("monthBox"); is "null" or just blank. I've also tried changing them to

currentyear = document.getElementById("yearBox").value;
currentmonth = document.getElementById("monthBox").value;


but have the same result.

Anyone know how to getting the values from the text boxes that come from when the server side script is ran? Is there something specific that must be done on the .net side of things?

Hope this makes sense.Just tried to put a textbox on my webform and alert the contents from a javascript fct.

alert(document.getElementById("TextBox1").value);
alert(this.WebForm4.TextBox1.value);
alert(document.WebForm4.TextBox1.value );

All 3 worked. (did have to add the .value though)

Only thing I can think of is perhaps the timing of the javascript event? Are the boxes dynamic or added to your form at design time? Also, how do you call the javascript?

Also, this is probably a silly remark, but watch out for case-sensativity.. In the visual studio you have name-completion but javascript in the HTML-design doesn't have it. (I was stuck with something similar today for an hour :o )

L.A.
 
Back
Top