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

ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
293 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 25,471 Reputation points Microsoft Vendor
    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