protected override void OnInit(EventArgs e) { base.OnInit(e); LoadXsl(); ProcessDataSources(); if (TemplateDef == null) { try { TemplateDef = TemplateDefinition.FromName(ClientID, DesignType, DesignStyle, true, XslSourceData, cached); TemplateDef.AddTemplateArguments(TemplateArguments, true); TemplateDef.AddClientOptions(ClientOptions, true); } catch (XsltException ex) { error = ex; SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); } } if (!prerendered) { if (TemplateDef != null) { TemplateDef.PreRender(Page); prerendered = true; } } }
internal virtual void PreRender() { TemplateDef.AddTemplateArguments(menuSettings.TemplateArguments, true); TemplateDef.AddClientOptions(menuSettings.ClientOptions, true); if (!String.IsNullOrEmpty(menuSettings.NodeXmlPath)) { LoadNodeXml(); } if (!String.IsNullOrEmpty(menuSettings.NodeSelector)) { ApplyNodeSelector(); } if (!String.IsNullOrEmpty(menuSettings.IncludeNodes)) { FilterNodes(menuSettings.IncludeNodes, false); } if (!String.IsNullOrEmpty(menuSettings.ExcludeNodes)) { FilterNodes(menuSettings.ExcludeNodes, true); } if (String.IsNullOrEmpty(menuSettings.NodeXmlPath) && !SkipLocalisation) { new Localiser(HostPortalSettings.PortalId).LocaliseNode(RootNode); } if (!String.IsNullOrEmpty(menuSettings.NodeManipulator)) { ApplyNodeManipulator(); } if (!menuSettings.IncludeHidden) { FilterHiddenNodes(RootNode); } var imagePathOption = menuSettings.ClientOptions.Find(o => o.Name.Equals("PathImage", StringComparison.InvariantCultureIgnoreCase)); RootNode.ApplyContext( imagePathOption == null ? DNNContext.Current.PortalSettings.HomeDirectory : imagePathOption.Value); TemplateDef.PreRender(); }
protected override void OnInit(EventArgs e) { LoadXsl(); ProcessDataSources(); formpanel = new UpdatePanel { ID = ID + "_UpdateFormPanel", RenderMode = UpdatePanelRenderMode.Block }; //, EnableViewState = true }; contenttemplate = new FormContentTemplate(); contenttemplate.WebPart = this; formpanel.ContentTemplate = contenttemplate; //Add on Page this.Controls.Add(formpanel); //Add Field Controls SetListFormFields(contenttemplate.canvas); formprogess = new UpdateProgress { AssociatedUpdatePanelID = formpanel.ID }; formprogess.ProgressTemplate = new FormProgessTemplate(); this.Controls.Add(formprogess); //if (TemplateDef == null) //{ try { TemplateDef = TemplateDefinition.FromName(contenttemplate.canvas.ClientID, FormType, FormStyle, true, XslSourceData, cached); TemplateDef.AddTemplateArguments(TemplateArguments, true); TemplateDef.AddClientOptions(ClientOptions, true); } catch (Exception) { } //} base.OnInit(e); }
public override void RenderWebPart(HtmlTextWriter writer) { string output = string.Empty; StringBuilder builder = new StringBuilder(); using (var baseWriter = new HtmlTextWriter(new StringWriter(builder, CultureInfo.InvariantCulture))) { bool configure = false; baseWriter.Write("<!-- Begin SharePresence FormWebPart - {0} {1} -->", FormType, FormStyle); if (TemplateDef != null) { List <TemplateArgument> args = new List <TemplateArgument>(); //var args = new XsltArgumentList(); if (!string.IsNullOrEmpty(FormTitle)) { args.Add(new TemplateArgument("FormName", FormTitle)); } if (!string.IsNullOrEmpty(FormDesciption)) { args.Add(new TemplateArgument("FormDescription", FormDesciption)); //args.AddParam("FormDescription", "", FormDesciption); } TemplateDef.AddTemplateArguments(args, false); //TemplateDef.TemplateArguments.ForEach(a => args.AddParam(a.Name, "", a.Value)); TemplateDef.AddClientOptions(new List <ClientOption> { new ClientString(FormType + "_FormOptions_", FormStyle) }, false); string data = string.Empty; try { GetListItems(out data); if (!string.IsNullOrEmpty(data)) { StringBuilder templatebuilder = new StringBuilder(); using (var templateWriter = new HtmlTextWriter(new StringWriter(templatebuilder, CultureInfo.InvariantCulture))) { TemplateDef.Render(data, templateWriter); } //Add Template for Canvas Render contenttemplate.innerHtml = templatebuilder.ToString(); //formpanel.Triggers.Add(contenttemplate.canvas as UpdatePanelTrigger); formpanel.RenderControl(baseWriter); } else { HttpApplication application = HttpContext.Current.ApplicationInstance; if (application.User.Identity.IsAuthenticated) { baseWriter.Write("No DataSource and or Style configured. "); if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit) { baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\" style=\"cursor: hand;\" >Configure</a>", StorageKey.ToString())); configure = true; } } } } catch (Exception ex) { baseWriter.Write(ex.Message); if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit) { baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\" style=\"cursor: hand;\" >Configure</a>", StorageKey.ToString())); configure = true; } } } else { HttpApplication application = HttpContext.Current.ApplicationInstance; if (application.User.Identity.IsAuthenticated) { baseWriter.Write("No DataSource and or Style configured. "); if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit) { baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\">Configure</a>", StorageKey.ToString())); configure = true; } } } baseWriter.Write("<!-- End SharePresence FormWebPart - {0} {1} -->", FormType, FormStyle); if (inEditMode) { if (!configure) { if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit) { baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\">Configure</a>", StorageKey.ToString())); } } menuControls.RenderControl(baseWriter); //base.RenderWebPart(baseWriter); } output = builder.ToString(); } writer.Write(output); }