[Mono-list] How to maintain values in a HtmlSelect when
modifying the content with javascript ?
Gonzalo Paniagua Javier
gonzalo@ximian.com
Fri, 12 Dec 2003 17:25:55 +0100
El vie, 12-12-2003 a las 13:59, Tiago Lima escribió:
> Hi,
>
> Ok, I tried with the DropDownList but It appears that the elements I add in
> javascript are not "added" when I post the page with the result. Perhaps
> meaning that the DropDownList doesnt add the elements on postback... ?
>
> I have to note that I add DropDownList's on PageLoad...
> So, I would like to know if I add a new one on PageLoad, just like I do with
> for example the TextBoxes, It can keep the state comming from the posted
> page... (the number of controls and the controls are the same in the posted
> page and the created page on PageLoad...) I dont know if you understand what
> I mean...
You cannot add items using javascript on the client side and expect the
server to know about that. If you want to do so, you need to roll your
our mechanism. I would suggest adding a hidden field with the values you
added (may be also a number) and re-create the control in Page_Load
using those hidden fields. May be you also want to derive from any of
the existing controls to implement this feature.
-Gonzalo