Re: Setting server-side textbox with javascript?



"VMI" <VMI@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B3922FF7-B984-44CB-9676-C94EEA801B61@xxxxxxxxxxxxxxxx

In the Page_Load() of my webForm, I have the following code, and on my
HTML
button, the onclick button calls writeVal() (the javascript function).
When
I click on the button, I see the messagebox from the Alert(), but the
server-side Textbox text is not set to 'TEST'. I get a javascript error
saying, "document.getElementById(...) is null or is not an object.".

What could the problem be? The textbox is inside a Wizard control.

The "problem" is exactly as you describe it - the textbox is inside a Wizard
control, which means that by the time the HTML comes to be rendered to the
browser, the client-side name of the textbox is no longer just txt_name -
it's probably something like the name of your Wizard control plus an
underscore plus "txt_name". Do a View Source and you'll see what I mean.

txt_name.ClientID will tell you the name of the textbox client-side i.e. the
name that the client-side JavaScript will need to reference.


.