在后台类中获取当前page对象

以前,在后台类里面要获取当前请求的一些信息的时候,就用HttpContext.Current对象,

可以获取诸如 Request,Response,Server等针对当前请求的对象,但是如何获得整个page对象,却一直不晓得。 今天在解答别人问题时候,无意中搜索发现,

System.Web.UI.Page page = HttpContext.Current.CurrentHandle as System.Web.UI.Page;

有什么用? 暂时想到的是可以用 page.ClientScript来注册脚本了,不用HttpContext.Current.Response.Write输出脚本在html源码的起始位置那么难看了

原文地址:https://www.cnblogs.com/lindping/p/2004839.html