开发者

How do i have my webpart detect whether it is hosted in Sharepoint or vanilla ASP .Net?

开发者 https://www.devze.com 2023-01-04 12:54 出处:网络
I have a suite of webpart controls that I maintain and develop for our main Sharepoint offerings. I also have an Asp .Net website which acts as a test suite for selenium scripts and unit tests.

I have a suite of webpart controls that I maintain and develop for our main Sharepoint offerings. I also have an Asp .Net website which acts as a test suite for selenium scripts and unit tests.

How can I determine from the web part code server code whether the control is currently being hosted in a Sharepoint page or whether the webpart is being hosted on a normal ASP .Net page? I'm looking to prepopulate some of the webpart properties with defaults but only when they exist in the ASP .Net page environment.开发者_StackOverflow中文版


if (this.WebPartManager.GetType().Name == "SPWebPartManager") { // SharePoint } else { // Not SharePoint }


You can probably test SPContext.Current.Web to be null

0

精彩评论

暂无评论...
验证码 换一张
取 消