读书人

关于类的方法参数传递有关问题

发布时间: 2012-03-28 15:40:03 作者: rapoo

关于类的方法参数传递问题
类的方法
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 ")
}
}

}

读书人网 >asp.net

热点推荐