简体   繁体   English

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

[英]how to access html control in static function (Asp.net)

I m trying to access html controls on my static function but im getting complie time error so please give me the solution 我正在尝试访问我的静态函数上的html控件,但是我遇到了complie time错误,因此请给我解决方案

here is my code 这是我的代码

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

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

and i tried the below solution so i got the null pointer exception 我尝试了以下解决方案,所以我得到了空指针异常

[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";                
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM