Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8925911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:49:36+00:00 2026-06-15T07:49:36+00:00

I’m running ASP.NET 4.0 WEBFORMS This problem bugs me… I ahve read up on

  • 0

I’m running ASP.NET 4.0 WEBFORMS

This problem bugs me… I ahve read up on a couple of threads on SO aswell as MSDN, but I think I’m missing the final piece of this Async puzzle….

What I want to accomplish is to update a label asynchronously, as a test I have set a button and a label. Then I have a loop which counts from 0 – 9 everytime the loop hits a number equal to or higher than seven i want it to update the label with the number.

I have gotten this to work synchronously, but then the label will end up showing only the last number. I have setup all methods and connected the event, but it won’t update even though I’m using beginInvoke and asyncresult.

At the moment it does not update at all, to much testing got me back to square one? I have managed to get it to update, I even trieds with system.threading.thread.sleep(3000), to see if it updated to quickly, but that didn’t work at all?

I’m puzzled anyone got a hint on how to achieve this?

Here’s my code

First my counter class

public class counter
{
public static event numberHandler FoundNumber;
public delegate void numberHandler(string position);

public void theAscendator()
{
    for (int i = 0; i < 10; i++)
    {
        if (i >= 7)
        {
            string labelText = i.ToString();

            if(FoundNumber != null)
            {
                FoundNumber.BeginInvoke(labelText, new AsyncCallback(this.SevenAndOver),null);                 
            }
        }
    }
}

public void SevenAndOver(IAsyncResult ar)
{
    FoundNumber.EndInvoke(ar);

} 

}

Now my mainpage(index.aspx) the codebehind

public partial class index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
private void index_FoundNumber(string position)
{

 //   Response.Write(position);

    Label1.Text = position;

    //   throw new NotImplementedException();
}
protected void Button1_Click(object sender, EventArgs e)
{
    counter counterClass = new counter();
    counterClass.theAscendator();        
    counter.FoundNumber += new counter.numberHandler(index_FoundNumber);
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:49:38+00:00Added an answer on June 15, 2026 at 7:49 am

    My guess is that you’re new to web, and that you’re probably a desktop guy (wpf/winforms.) This kind of question is all to common for people like you making the transition from single-tier applications. You have to remember that despite the webforms model looking like winforms, it’s nothing of the sort. It’s a thin veil over a stateless request/response client/server model – i.e. HTTP.

    The reason this doesn’t work is simply because when the asynchronous counter class completes, the page request has already completed. There is no way for you to modify the html because it’s already been sent back to the browser. Once the click handler completes, the page is “done.” Server-side asynchronous code in asp.net essentially runs “headless.” It’s best used to do some work that no longer requires the client.

    So, how would you do this? Well, it’s not obvious at first but asynchronous web work is typically driven by the client, not the server. The client being the browser, and the technology being AJAX – Asynchronous JavaScript and XML. The idea is that the event is handled on the server, the page is returned and then javascript on the client will poll the server for new data without making a full postback of the page.

    Now that I’ve said all that, there is in fact a way to emulate two way asynchronicity but without an understanding of the fundamentals, you may find it tough going. If you’re interested, the technology is called SignalR (http://signalr.net/). This allows the server (asp.net C#) to call methods on the client (javascript), and vice versa.

    So, my advice would be to first understand the HTTP model at a fundamental level, then start looking at abstractions like ASP.NET.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.