I have developed a quick base part for using the radwindowmanager on a sharepoint site. My requirement was to have various webparts that could open a rad window from links, such as news and events. Here is my base class. What do you think? The skin is hardcoded, but that could easily be changed. I have found that this seems to work pretty well for what I am trying to do.
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Reflection;
using Telerik.Web.UI;
using Telerik.Charting.Styles;
namespace SunGard.Portal.WebParts.Controls {
public class BaseWindowPart : System.Web.UI.WebControls.WebParts.WebPart {
private const string javascriptIncludeKey = "SunGardPortalWebPartsClientScript";
private const string javascriptFilePath = "SunGardPortalWebPartsClientScript.js";
private RadWindowManager windowManager;
private RadWindow popupWindow;
protected string radWindowClientName = "SPRadWindow";
protected override void OnLoad(EventArgs e) {
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsClientScriptIncludeRegistered(typeof(Page), javascriptIncludeKey)) {
string scriptUrl = cs.GetWebResourceUrl(this.GetType(), String.Format("{0}.{1}", Assembly.GetExecutingAssembly().GetName().Name, javascriptFilePath));
cs.RegisterClientScriptInclude(typeof(Page), javascriptIncludeKey, scriptUrl);
}
base.OnLoad(e);
}
protected override void CreateChildControls() {
base.CreateChildControls();
if (Page.FindControl("SPRadWindow") == null) {
windowManager = new RadWindowManager();
windowManager.ID = "SPRadWindow";
windowManager.Skin = "WebBlue";
Controls.Add(windowManager);
popupWindow = new RadWindow();
popupWindow.ReloadOnShow = true;
Controls.Add(popupWindow);
}
}
}}
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Reflection;
using Telerik.Web.UI;
using Telerik.Charting.Styles;
namespace SunGard.Portal.WebParts.Controls {
public class BaseWindowPart : System.Web.UI.WebControls.WebParts.WebPart {
private const string javascriptIncludeKey = "SunGardPortalWebPartsClientScript";
private const string javascriptFilePath = "SunGardPortalWebPartsClientScript.js";
private RadWindowManager windowManager;
private RadWindow popupWindow;
protected string radWindowClientName = "SPRadWindow";
protected override void OnLoad(EventArgs e) {
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsClientScriptIncludeRegistered(typeof(Page), javascriptIncludeKey)) {
string scriptUrl = cs.GetWebResourceUrl(this.GetType(), String.Format("{0}.{1}", Assembly.GetExecutingAssembly().GetName().Name, javascriptFilePath));
cs.RegisterClientScriptInclude(typeof(Page), javascriptIncludeKey, scriptUrl);
}
base.OnLoad(e);
}
protected override void CreateChildControls() {
base.CreateChildControls();
if (Page.FindControl("SPRadWindow") == null) {
windowManager = new RadWindowManager();
windowManager.ID = "SPRadWindow";
windowManager.Skin = "WebBlue";
Controls.Add(windowManager);
popupWindow = new RadWindow();
popupWindow.ReloadOnShow = true;
Controls.Add(popupWindow);
}
}
}}