www.webdeveloper.com
Results 1 to 2 of 2

Thread: .net mix with javascript

  1. #1
    Join Date
    Jul 2004
    Posts
    46

    Question .net mix with javascript

    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

    Code:
    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

    Code:
    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.
    I have an IQ of 134 or something like that. I forget.

  2. #2
    Join Date
    Oct 2005
    Posts
    5
    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 )

    L.A.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles