Ejemplo n.º 1
0
        /// <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();

            PageSkinUI ps = new PageSkinUI {
                Collection = model.Collection,
                FileName   = model.FileName,
            };

            Setup setup = new Setup {
                AjaxUrl = Utility.UrlFor(typeof(SkinController), nameof(SkinController.GetPageSkins)),
            };

            // add dummy input field so we can find the property name in this template
            hb.Append($@"
<div id='{ControlId}' class='yt_pageskin 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.PageSkinEditComponent('{ControlId}', {Utility.JsonSerialize(setup)});");
            }
            return(hb.ToString());
        }
Ejemplo n.º 2
0
        /// <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();

            PageSkinUI ps = new PageSkinUI {
                Collection = model.Collection,
                FileName   = model.FileName,
            };

            using (Manager.StartNestedComponent(FieldName)) {
                hb.Append($@"
<div id='{ControlId}' class='yt_pageskin 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());
        }