asp.net - Using C#, how can I update listbox Items from another class? -


hy,

in project asp.net (c#), using threading process messages. have display page contain listbox actions taken in processing message. , class processing message.

default.aspx:

        protected void page_load(object sender, eventargs e)         {             //starts thread , call method process.cs         }          public void setlistitem(string text)         {             mylistbox.items.add(text);             mylistbox.databind();         } 

process.cs

public class process {   public process()   {     default defaultpage;     defaultpage.setlistitem("==> received message!");   } } 

but listbox not show nothing. has ideea i'm wrong? thanks.

jeff

remove databind

 mylistbox.databind(); 

you don't need since adding item list collection. if setting datasource property, have use it. depending on in life-cycle update firing well. update being replaced code somewhere else in process well.

in truth, take out of being separate thread. since need updated before page submits information browser, either need keep in same thread make sure completes, or you're going need have sort of check @ end of page executing process make sure has finished. possible thread completing after page has finished processing.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -