Invoking in asp.net C#

  • Thread starter Thread starter Oitne.Inside
  • Start date Start date
O

Oitne.Inside

Hi there,

I'm trying to make a basic app in asp.net written in C#. I managed to
get it working in a appliaction, but when i make inside an
webapplication, it wont work. Any ideas?

private void Nameserver_SignedIn(object sender, EventArgs e)
{
UpdateContactListDelegate updateListBox = new
UpdateContactListDelegate(this.UpdateContactList);
--> ListBox1.Invoke(updateListBox);
}

public delegate void UpdateContactListDelegate();
private void UpdateContactList()
{
ListBox1.Items.Clear();
System.Windows.Forms.MessageBox.Show("D");
foreach (Contact contact in msn.ContactList.All)
{
this.ListBox1.Items.Add("C: " + contact.Name);
}

}

The problem occures at "ListBox1.Invoke(updateListBox);". I have to
invoke it couse it goed cross threading. The error i get is
"System.Web.UI.WebControls.ListBox' does not contain a definition for
'Invoke"
 
That's correct. You're thinking web controls behave like Windows Forms
controls, and they do not. A web page is stateless, and the entire Page class
is gone once the page has been sent to the browser.

Events in ASP.NET are handled via the postback mechanism.
You can get a lot of very helpful info at the asp.net site. Look for
"QUICKSTART".

-Peter

Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
 
That's correct. An ASP.Net application is not single-threaded, so you can
simply call the method.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
Back
Top