HtmlSelect Problem

haycee

New Member
I'm trying to use a HtmlSelect control on a page, because I'm doing a lot of client side scription. While the user interacts with the page, items get added to the select list. But when the form gets posted back to the server, they aren't there. Here is some code:<BR><BR>Here is the tag declaring the list in the HTML:<BR><select id="lstIntervals" onchange="clearIntervalIfEditing()" size="5" name="lstIntervals" runat="server"></select><BR><BR>Here is the button that submits the form:<BR><input id="btnUpdateWorkout" onclick="submitForm()" type="button" value=http://aspmessageboard.com/archive/index.php/"Finished" name="btnUpdateWorkout" runat="server"><BR><BR>Here is the submitForm() function:<BR>function submitForm() {<BR>&nbsp;&nbsp;alert( document.edit.lstIntervals.options.length );<BR>&nbsp;&nbsp;document.edit.submit();<BR>}<BR><BR>(That alert throws up the number of elements in the list box when it is submitted.)<BR><BR>Here is the code checking the number of elements in the list on the server side of the code (after being posted back):<BR>Response.Write( lstIntervals.Items.Count );<BR><BR>(This writes out 0 to the page.)<BR><BR>I'm hoping that I'm just missing an attribute here or there, or something simple. It would really help if someone could spot something out of there. Thanks for looking...It would appear you have hit on a limitation of RUNAT=SERVER controls.<BR><BR>Since there is nothing telling the server that the list on the client was changed, the server simply maintains the original list.<BR><BR>I think you'll have to write your own control (or extend the standard one?) to make this work. Or somehow post info back to the server that will cause it to update its "memory" of the list of <OPTION>s.<BR><BR>
 
Back
Top