ASP.NET / DropDownlist JavaScript Problem

bungpeng

Senior Contributor
Joined
Sep 10, 2002
Messages
906
Location
Malaysia
How can I get my JavaScript-added items to appear when I get to the .NET world?

I have an ASP.NET DropDownList server control which gets populated on the client side via JavaScript, like so:

var oOption = document.createElement('OPTION');
oOption.value = sText;
oOption.text = sText;
listbox.options.add(oOption);

When a postback occurs (via another control--this control does not have AutoPostBack set), this ListBox doesn't contain crap. It's empty.

I've tried checking it for contents in Page_Load() and in some of the handlers. Nowhere does it seem to arrive with the items I added through JavaScript.
 
it is not working... i had use both methods, I found that there is no different when I disable or enable the viewstate in control's properties
 
alternative
what if you create a hidden input and add the values to there? try with the runat attribute set to server and with the runat attribute removed.
 
HJB417 said:
alternative
what if you create a hidden input and add the values to there? try with the runat attribute set to server and with the runat attribute removed.

what do you mean that?

My solution is using hidden input to keep my value,
but it is quite manual, so I looking for better way
 
Back
Top