Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscpae looses textbox.text content

Status
Not open for further replies.

crazyboybert

Programmer
Jun 27, 2001
798
GB
Hi All

I have a asp:textbox on my page which may or may not have a value when the page is loaded. When a html radio button elsewhere in the form is clicked clientside javascript is used to set the value of the textbox using..

document.getElementById(textboxID).value = value;

The form is then submitted using Javascript. On the server the value of the textbox is accessed via the textboxID.Text property.

This works fine in IE where the new value given to the textbox with javascript persists to the server.However with Netscape 6.0 this value dissappears. If I alert the value clientside after it has been reassigned it matches the new value as normal but this new value is not reflected in the textbox.Text property when it reaches the server.

Has anyone experienced this sort of problem with NS? Is there something I can do to workaround - or does Netscape dynamically update the textbox in such a fashion that its value is not avaiable via the Text property?

Bizarrely if I request the value of the textbox on the server using
Code:
Request.Form[i].ToString()
then it is there as would be expected....

Any thoughts greatly appreciated as this one has me stumped!

Cheers

Rob

------------------------------------

Go placidly amidst the noise and haste,
find what peace there may be in silence.
-Anon

------------------------------------
 
HI crazyboybert,

When a web form is posted back to the server before the page_load event fires another event called the page_init fires. In the page_init routine, values that you entered in the html page are assigned to the respective input controls by .NET and are then available for use in the page_load and so on.

You must remember that the controls that you create on a web form are merely components on a web form. They are destroyed the moment the web form is converted into HTML and send to the client side. When a post back occurs, the web form is recreated, together with all the input controls. In the page_init the values that you entered into the corresponding HTML input box is assigned to the TextBox webcontrol. This is done behind the scenes by .NET

You say it works fine with IE but not NS. Not surprising at all. I think it may have to do with the logic in page_init which recreates all web controls and assigns values. .NET , I am guessing links the HTML input box with its corresponding Textbox webcontrol using some clientID which it assigns when it creates the HTML input box initially. Maybe NS screws up here. I am just guess here and I may be wrong.

laters
 
I just don't get how "NS can screw up here" - I know this sort of thing is usually NS but in this instance i can't see it.

Using Javascript I update the textbox value and alert it just before submitting the form. In both browsers this works as expected yet with NS the value doesnt make it back to the server. It still appears in the Form collection though. Wierd huh.

Anyone got any ideas of another method of sending a value back to the server on postback other than making it the value of a form field using javascript?

cheers

Rob

------------------------------------

Go placidly amidst the noise and haste,
find what peace there may be in silence.
-Anon

------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top