关于类的方法参数传递问题
类的方法
public static getcontrol()
{
.......
Control control_lr = Page.FindControl( "txtbox ")
.......
}
这个Page页面,也就是调用方法的页面能作为参数传递进来吗?如果能,该怎么做呢?谢谢
------解决方案--------------------public static getcontrol()
{
HttpContext ctx = HttpContext.Current;
if ( ctx != null )
{
System.Web.UI.Page page = ctx.Handler as System.Web.UI.Page;
Control control_lr = page.FindControl( "txtbox ")
}
.......
}
------解决方案--------------------public static getcontrol()
{
HttpContext ctx = HttpContext.Current;
if ( ctx != null )
{
System.Web.UI.Page page = ctx.Handler as System.Web.UI.Page;
if(page != null)
{
Control control_lr = page.FindControl( "txtbox ")
}
}
}