|
Subject:
|
Capturing Dynamically Added Client Values
|
|
Posted By:
|
Colonel Angus
|
Post Date:
|
4/13/2006 2:56:30 PM
|
I have a listbox that was added to the page at design time. On the HTML side, I have javascript code that adds items to the listbox.
On postback, those values are lost. How can I retain those values for use on the server side?
Thank you in advance for your comments.
|
|
Reply By:
|
jbenson001
|
Reply Date:
|
4/14/2006 12:25:10 PM
|
i guess with JS you would have to load the values each time. I usually do it in the code behind, page_init event
dim lb as new listbox lb.id = "sdfsd" lb.itmes.add(..add items here.)
me.findcontrol("Form1").controls.add(lb)
Jim
|
|
Reply By:
|
Colonel Angus
|
Reply Date:
|
4/14/2006 12:30:46 PM
|
I was trying a similar line of thought when I tried to use page_init in conjunction with FindControl, but I just couldn't get everything I needed to persist.
However, I did find something very interesting. If instead of using a listbox to have js add items to, I used a textbox to gather the js info (as an appended string that I would later use Split function on) - it would persist what I added on postback.
I suppose I should have known this going in, but I got frustrated trying to get the %$!#ing listbox to work.
Thanks for your reply! Have a great weekend.
|
|
Reply By:
|
jbenson001
|
Reply Date:
|
4/14/2006 12:36:43 PM
|
not sure why it wouldn't be persisted. I just did a quick test and worked fine. If you have it working then keep it that way :)
|
|
Reply By:
|
Colonel Angus
|
Reply Date:
|
4/14/2006 12:38:42 PM
|
I once had a professor that said "Nothing succeeds like success".
|