[英]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";
}
}
you can use AJAX and JQuery for that these 3 links will help you 您可以使用AJAX和JQuery,这3个链接将为您提供帮助
Accessing runat="server" control id in WebMethod 在WebMethod中访问runat =“ server”控件ID
http://forums.asp.net/t/1580317.aspx?Access+Server+control+in+web+method+ http://forums.asp.net/t/1580317.aspx?Access+Server+control+in+web+method+
http://www.itorian.com/2012/07/calling-aspnet-c-method-web-method.html http://www.itorian.com/2012/07/calling-aspnet-c-method-web-method.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.