Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 474.3k

Web form error has an error on Default.aspx

Nov 11 2020 8:24 AM
Hi Team
 
If you have an error when creating a web form, error "Compiler Error Message: CS1061: 'default_aspx' does not contain a definition for 'btnStart_Click' and no accessible extension method 'btnStart_Click' accepting a first argument of type 'default_aspx' could be found (are you missing a using directive or an assembly reference?)
  1. //Default.aspx  
  2. <asp:Button ID="btnStart" runat="server" OnClick="btnStart_Click" /> // Error is on this line, how to resolve this?  
  3. <asp:TextBox ID="SomeText" runat="server"></asp:TextBox>  
  1. //Default.cs    
  2. string results;    
  3. private async void btnStart_Click(object sender, EventArgs e)    
  4. {    
  5.     SaySomething();    
  6.     SomeText.Text = results;    
  7. }    
  8.   
  9. async System.Threading.Tasks.Task<string> SaySomething()    
  10. {    
  11.     await System.Threading.Tasks.Task.Delay(1000);    
  12.     results = "Hello result";    
  13.     return results;    
  14. }  

Answers (1)