Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Invoking in asp.net C#

 
Thread Tools Search this Thread
Old 09-21-2007, 11:12 AM   #1
Default Invoking in asp.net C#


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"



Oitne.Inside@gmail.com
  Reply With Quote
Old 09-21-2007, 12:20 PM   #2
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
 
Posts: n/a
Default RE: Invoking in asp.net C#
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



"" wrote:

> 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"
>
>



=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
  Reply With Quote
Old 09-21-2007, 12:20 PM   #3
Kevin Spencer
 
Posts: n/a
Default Re: Invoking in asp.net C#
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

<> wrote in message
news: ups.com...
> 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"
>





Kevin Spencer
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT Help needed with ASP.NET Compilation error nunu_bug General Help Related Topics 0 08-06-2009 01:26 PM
viewstate MAC failed in asp.net 2.0 while postback the page azraffarveen Software 0 05-12-2009 03:24 PM
.NET 2.0 Web Apps / .NET 3.5 ASP.NET Apps - Differences/Similariti london1919 MCTS 1 12-08-2008 03:16 PM
ASP.NET: Asign Users in Roles(Array.IndexOf(Of String) method) msandlana Software 0 04-25-2008 06:37 AM
ASP.NET 2.0 application does not run in WIN2k3 johnfraj Software 0 04-19-2007 08:27 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46