async Task c# webform

Ruwan Ratnayake 1 Reputation point
2022-12-16T07:56:24.697+00:00

I need to create a webform with async Task

When I click a button, I need to get return of async Task to webform lable

Can anyone help me

Developer technologies | ASP.NET | ASP.NET API
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 30,206 Reputation points Microsoft External Staff
    2022-12-16T09:29:34.907+00:00

    Hi @Ruwan Ratnayake ,
    You can study this document, which contains detailed steps to implement asynchronous web forms.
    https://learn.microsoft.com/en-us/aspnet/web-forms/overview/performance-and-caching/using-asynchronous-methods-in-aspnet-45#CreatingAsynchGizmos
    ASP.NET asynchronous pages must include the Page directive with the Async attribute set to "true".
    I wrote a simple example, you can refer to:
    ![271318-image.png]1

    private async Task GetGizmosSvcAsync()  
            {  
                Label1.Text = "Test";  
            }  
    
            protected void Button1_Click(object sender, EventArgs e)  
            {  
                RegisterAsyncTask(new PageAsyncTask(GetGizmosSvcAsync));  
            }  
    

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.