| <asp:scriptmanager runat="server" id="ScriptManager1"> |
| </asp:scriptmanager> |
| Widget Configuration: |
| <asp:textbox maxlength="20" runat="server" id="TextConfiguration"></asp:textbox> |
| <asp:dropdownlist runat="server" id="ListWidgets"> |
| </asp:dropdownlist> |
| <asp:button runat="server" id="ButtonAddDock" text="Add Dock" onclick="ButtonAddDock_Click" /> |
| <asp:UpdatePanel ID="ParentUpdatePanel" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional" > |
| <ContentTemplate> |
| <telerik:raddocklayout id="DockLayout" runat="server" onloaddocklayout="DockLayout_LoadDockLayout" |
| onsavedocklayout="DockLayout_SaveDockLayout" storelayoutinviewstate="false"> |
| <div> |
| <telerik:raddockzone runat="server" id="ZoneLeft" style="float: left; margin-right: 10px;" |
| width="45%" minheight="200px"> |
| </telerik:raddockzone> |
| <telerik:raddockzone runat="server" id="ZoneRight" style="float: left;" minheight="200px" |
| width="45%"> |
| </telerik:raddockzone> |
| </div> |
| <div style="display: none"> |
| <asp:updatepanel runat="server" id="UpdatePanel1"> |
| <triggers> |
| <asp:asyncpostbacktrigger controlid="ButtonAddDock" eventname="Click" /> |
| </triggers> |
| </asp:updatepanel> |
| </div> |
| </telerik:raddocklayout> |
| </ContentTemplate> |
| </asp:UpdatePanel> |
| public partial class _Default : System.Web.UI.Page |
| { |
| int PageID = 1; |
| List<PageWidgetInfo> _pageWidgets; |
| protected List<PageWidgetInfo> PageWidgets |
| { |
| get |
| { |
| if (_pageWidgets == null) |
| { |
| _pageWidgets = PageWidgetInfo.SelectPageWidgets(PageID); |
| _pageWidgets.Sort(); |
| } |
| return _pageWidgets; |
| } |
| } |
| protected override void OnInit(EventArgs e) |
| { |
| foreach (PageWidgetInfo pageWidget in PageWidgets) |
| { |
| RadDock dock = CreateDock(pageWidget); |
| DockLayout.Controls.Add(dock); |
| CreateSaveStateTriggers(dock); |
| } |
| base.OnInit(e); |
| } |
| protected override void OnLoad(EventArgs e) |
| { |
| ScriptManager1.RegisterAsyncPostBackControl(TriggerAsyncPostback); |
| if (!IsPostBack) |
| { |
| ListWidgets.DataSource = WidgetInfo.Select(); |
| ListWidgets.DataTextField = "Name"; |
| ListWidgets.DataValueField = "ID"; |
| ListWidgets.DataBind(); |
| } |
| base.OnLoad(e); |
| } |
| protected RadDock CreateDock(PageWidgetInfo pageWidgetInfo) |
| { |
| RadDock dock = new RadDock(); |
| dock.ApplyState(DockState.Deserialize(pageWidgetInfo.State)); |
| dock.ID = pageWidgetInfo.ID.ToString(); |
| dock.Tag = pageWidgetInfo.ID.ToString(); |
| BaseWidget widget = LoadControl(pageWidgetInfo.Path) as BaseWidget; |
| if (widget == null) |
| { |
| throw new Exception(string.Format("The UserControl with path '{0}' does not inherit from BaseWidget. All widgets must inherit from BaseWidget.", pageWidgetInfo.Path)); |
| } |
| widget.Configuration = pageWidgetInfo.Configuration; |
| dock.ContentContainer.Controls.Add(widget); |
| //Currently, there is a problem with the RadDock command items: |
| // if they are not explicitly created, the Command event it not fired. |
| dock.Commands.Add(new DockCloseCommand()); |
| dock.Commands.Add(new DockExpandCollapseCommand()); |
| dock.Command += new DockCommandEventHandler(Dock_Command); |
| return dock; |
| } |
| protected RadDock CreateDock(int widgetID, string widgetConfiguration) |
| { |
| WidgetInfo widget = WidgetInfo.Select(widgetID); |
| if (widget == null) |
| { |
| throw new Exception(string.Format("Cannot find a Widget with ID={0}.", widgetID)); |
| } |
| PageWidgetInfo newPageWidget = PageWidgetInfo.Insert(PageID, widgetID, widgetConfiguration, string.Empty); |
| PageWidgets.Add(newPageWidget); |
| RadDock dock = CreateDock(newPageWidget); |
| dock.Title = widget.Name; |
| return dock; |
| } |
| protected void Dock_Command(object sender, DockCommandEventArgs e) |
| { |
| if (e.Command.Name == "Close") |
| { |
| ScriptManager.RegisterStartupScript( |
| UpdatePanel1, |
| this.GetType(), |
| "RemoveDock", |
| string.Format("function _removeDock() {{" + |
| "Sys.Application.remove_load(_removeDock);" + |
| "$find('{0}').undock();" + |
| "$get('{1}').appendChild($get('{0}'));" + |
| "$find('{0}').doPostBack('DockPositionChanged');" + |
| "}};" + |
| "Sys.Application.add_load(_removeDock);", ((RadDock)sender).ClientID, UpdatePanel1.ClientID), |
| true); |
| } |
| } |
| private PageWidgetInfo FindWidget(int id) |
| { |
| foreach (PageWidgetInfo info in PageWidgets) |
| { |
| if (info.ID == id) return info; |
| } |
| return null; |
| } |
| protected void DockLayout_SaveDockLayout(object sender, DockLayoutEventArgs e) |
| { |
| foreach (DockState state in DockLayout.GetRegisteredDocksState()) |
| { |
| int stateWidgetID = int.Parse(state.Tag); |
| PageWidgetInfo pageWidget = FindWidget(stateWidgetID); |
| if (pageWidget != null && !state.Closed) |
| { |
| pageWidget.State = state.ToString(); |
| pageWidget.Update(); |
| } |
| else |
| { |
| PageWidgetInfo.Delete(stateWidgetID); |
| } |
| } |
| } |
| private void CreateSaveStateTriggers(RadDock dock) |
| { |
| dock.AutoPostBack = true; |
| dock.CommandsAutoPostBack = true; |
| AsyncPostBackTrigger saveStateTrigger = new AsyncPostBackTrigger(); |
| saveStateTrigger.ControlID = dock.ID; |
| saveStateTrigger.EventName = "DockPositionChanged"; |
| UpdatePanel1.Triggers.Add(saveStateTrigger); |
| saveStateTrigger = new AsyncPostBackTrigger(); |
| saveStateTrigger.ControlID = dock.ID; |
| saveStateTrigger.EventName = "Command"; |
| UpdatePanel1.Triggers.Add(saveStateTrigger); |
| } |
| protected void ButtonAddDock_Click(object sender, EventArgs e) |
| { |
| RadDock dock = CreateDock(int.Parse(ListWidgets.SelectedValue), TextConfiguration.Text); |
| UpdatePanel1.ContentTemplateContainer.Controls.Add(dock); |
| CreateSaveStateTriggers(dock); |
| ScriptManager.RegisterStartupScript( |
| dock, |
| this.GetType(), |
| "AddDock", |
| string.Format(@"function _addDock() {{" + |
| "Sys.Application.remove_load(_addDock);" + |
| "$find('{1}').dock($find('{0}'));" + |
| "$find('{0}').doPostBack('DockPositionChanged');" + |
| "}};" + |
| "Sys.Application.add_load(_addDock);", dock.ClientID, ZoneLeft.ClientID), |
| true); |
| } |
| protected void DockLayout_LoadDockLayout(object sender, DockLayoutEventArgs e) |
| { |
| foreach (PageWidgetInfo pageWidget in PageWidgets) |
| { |
| e.Indices[pageWidget.DockState.UniqueName] = pageWidget.DockState.Index; |
| e.Positions[pageWidget.DockState.UniqueName] = pageWidget.DockState.DockZoneID; |
| } |
| } |
| protected override bool OnBubbleEvent(object source, EventArgs e) |
| { |
| Type type = source.GetType(); |
| string souceName = type.ToString(); |
| if ((e is CommandEventArgs) && souceName.Equals("System.Web.UI.WebControls.Button")) |
| { |
| Button temp = (Button)source; |
| if(temp.ID.Equals("Button1")) |
| { |
| TriggerAsyncPostback_Click(source, e); |
| } |
| return true; |
| } |
| return false; |
| } |
| protected void TriggerAsyncPostback_Click(object sender, EventArgs e) |
| { |
| CommandEventArgs args = (CommandEventArgs)e; |
| string configuration = (string)args.CommandArgument; |
| string ID = (string)args.CommandName; |
| //recreate it with the new data |
| PageWidgetInfo pageWidgetInfo = FindWidget(int.Parse(ID)); |
| pageWidgetInfo.Configuration = configuration; |
| //delete all docks from the zones |
| foreach (RadDockZone zone in DockLayout.RegisteredZones) |
| { |
| zone.Controls.Clear(); |
| } |
| //update DockLayout by updating the panel |
| ParentUpdatePanel.Update(); |
| } |
| } |
I found an error returned with the event from server when I was creating a Personal Site. The error ids were 5187 and 6151. We activated the RadEditor feature when the personal site is created. In our test case, if we create a few sites at the same time, it will be sucessful. But if we create many sites at the same time (12 sites/min), it always return an error.
The error message :at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
at Telerik.SharePoint.RadEditorFeature.RadFeatureReceiver.FeatureActivated(SPFeatureReceiverProperties properties)
at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce)
at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boolean fForce)
...
Best Regards,
lee
To customize a RadHtmlField we managed adding a project specific CSS file easily:
:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
base.radEditorControl.AllowScripts = true;
base.radEditorControl.CssFiles = new string[]{ "/styles/css/styles.css" };
:
The editor shows all classes that can be found in styles.css in the "Apply CSS class" dropdown. Cool.
Beside a lot of other style definitions this CSS file contains classes like:
.SaiaStylesCustom-Saia-Text
{
font-size: 12px;
font-weight: normal;
font-family: Arial, Helvetica, sans-serif;
color: #212121;
}
We now would like to see just these .SaiaStylesCustom-xxx-xxx classes in the dropdown. Therefore we added the following in the OnLoad event handler:
:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
base.radEditorControl.AllowScripts = true;
base.radEditorControl.CssFiles = new string[] { "/styles/css/editorstyles.css" };
try
{
base.radEditorControl.CssClasses.Add(".SaiaStylesCustom-Saia-Text ", ".SaiaStylesCustom-Saia-Text");
:
We expected the dropdown to show just the classes we added, but we still can see all the other once present in the CSS file. Any idea what we're doing wrong? Help would be appreciated.

