开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜