0

我通过 jquery 调用我的服务器端方法,并从该方法中我试图访问页面控制但给出错误。这是我的示例代码

    [WebMethod]
    public static findEvents(string PID)
    {
        Page page = HttpContext.Current.Handler as Page;
        Panel pn=(Panel)page.FindControl("hdContainer");
    }

but find control gives null error. please give any solution to find control in static method.
4

1 回答 1

0

我搜索过这样的东西。

静态方法不能引用实例引用。您需要从类中的其他实例方法传入对 HttpContext 或页面本身的引用。我认为您需要使用如下参数调用静态 Web 服务:

[WebMethod]
public static findEvents(string PID, System.Web.UI.Page page)
{        
    Panel pn=(Panel)page.FindControl("hdContainer");
}

它可能会帮助你。

于 2012-12-07T06:34:22.100 回答