首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-03-28 
关于类的方法参数传递问题类的方法publicstaticgetcontrol(){.......Controlcontrol_lrPage.FindControl(

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

}

热点排行