/// <summary> /// Called by the framework when the component needs to be rendered as HTML. /// </summary> /// <param name="model">The model being rendered by the component.</param> /// <returns>The component rendered as HTML.</returns> public async Task <string> RenderAsync(SkinDefinition model) { HtmlBuilder hb = new HtmlBuilder(); PopupSkinUI ps = new PopupSkinUI { Collection = model.Collection, FileName = model.FileName, }; Setup setup = new Setup { AjaxUrl = Utility.UrlFor(typeof(SkinController), nameof(SkinController.GetPopupPageSkins)), }; // add dummy input field so we can find the property name in this template hb.Append($@" <div id='{ControlId}' class='yt_popupskin t_edit'> {await HtmlHelper.ForEditComponentAsync(Container, PropertyName, "-", "Hidden", HtmlAttributes: new { __NoTemplate = true, @class = Forms.CssFormNoSubmit })}"); using (Manager.StartNestedComponent(FieldName)) { hb.Append($@" <div class='t_collection'> {await HtmlHelper.ForLabelAsync(ps, nameof(ps.Collection))} {await HtmlHelper.ForEditAsync(ps, nameof(ps.Collection))} </div> <div class='t_skin'> {await HtmlHelper.ForLabelAsync(ps, nameof(ps.FileName))} {await HtmlHelper.ForEditAsync(ps, nameof(ps.FileName))} </div> </div>"); Manager.ScriptManager.AddLast($@"new YetaWF_ComponentsHTML.PopupSkinEditComponent('{ControlId}', {Utility.JsonSerialize(setup)});"); } return(hb.ToString()); }
/// <summary> /// Called by the framework when the component needs to be rendered as HTML. /// </summary> /// <param name="model">The model being rendered by the component.</param> /// <returns>The component rendered as HTML.</returns> public async Task <string> RenderAsync(SkinDefinition model) { HtmlBuilder hb = new HtmlBuilder(); PopupSkinUI ps = new PopupSkinUI { Collection = model.Collection, FileName = model.FileName, }; using (Manager.StartNestedComponent(FieldName)) { hb.Append($@" <div id='{ControlId}' class='yt_popupskin t_display'> <div class='t_collection'> {await HtmlHelper.ForLabelAsync(ps, nameof(ps.Collection))} {await HtmlHelper.ForDisplayAsync(ps, nameof(ps.Collection))} </div> <div class='t_skin'> {await HtmlHelper.ForLabelAsync(ps, nameof(ps.FileName))} {await HtmlHelper.ForDisplayAsync(ps, nameof(ps.FileName))} </div> </div>"); } return(hb.ToString()); }