Private static readonly object ReflectionLock = new object(); Lock (ReflectionLock) { Type scriptManagerType = Type.GetType( "System.Web.UI.ScriptManager, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35", false); if (scriptManagerType != null) // ASP.NET AJAX is installed. else // ASP.NET AJAX is not installed.
检查是否已为单个页启用 AJAX 功能
ScriptManager sm = ScriptManager.GetCurrent(Page) if (sm == null) { // ASP.NET AJAX functionality is not enabled for the page. } else { // AJAX functionality is enabled for the page. }
来自:http://msdn.microsoft.com/zh-cn/library/bb907614.aspx
同样,可以通过此方法,对其它的组件进行判断,如ActiveReport的判断 "DataDynamics.ActiveReports.Web.Handlers.CompiledReportHandler, ActiveReports.Web, Version=5.1.0.158, Culture=neutral, PublicKeyToken=cc4967777c49a3ff",
这个信息是从WebConfig文件中得到的。(不安装时会报错。查看相应的错误语句)
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />
<add verb="*" path="*.rpx" type="DataDynamics.ActiveReports.Web.Handlers.RpxHandler, ActiveReports.Web, Version=5.1.0.158, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />