如何在静态函数中访问html控件(Asp.net)

时间:2016-02-26 05:05:40

标签: c# asp.net .net asmx webmethod

我试图在我的静态函数上访问html控件但是我得到了complie时间错误 所以请给我解决方案

这是我的代码

[System.Web.Services.WebMethod]    
public static void btnPostNote_Click(string note)
{
    string borrowerId = Data.QueryString("id");

    note = "";
    RefreshNotes(borrowerId);
    lblNoteSaved.Text = "Note Successfully Saved
}

我尝试了下面的解决方案,所以我得到了空指针异常

[System.Web.Services.WebMethod]
public static void btnPostNote_Click(string note)
{
   if (HttpContext.Current != null)
   {
     Page page = (Page)HttpContext.Current.Handler;
     Label lblNoteSaved = (Label)page.FindControl("lblNoteSaved");
     string borrowerId = Data.QueryString("id");

     note = "";
     RefreshNotes(borrowerId);
     lblNoteSaved.Text = "Note Successfully Saved";                
   }
}