Show / Hide Table of Contents

    Class SectionExtensions

    Extension methods to create form sections.

    Inheritance
    System.Object
    SectionExtensions
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: ChameleonForms.Component
    Assembly: ChameleonForms.dll
    Syntax
    public static class SectionExtensions

    Methods

    | Improve this Doc View Source

    BeginSection<TModel>(ISection<TModel>, IHtmlContent, IHtmlContent, HtmlAttributes)

    Creates a nested form section.

    Declaration
    public static Section<TModel> BeginSection<TModel>(this ISection<TModel> section, IHtmlContent heading, IHtmlContent leadingHtml = null, HtmlAttributes htmlAttributes = null)
    Parameters
    Type Name Description
    ISection<TModel> section

    The section the section is being created under

    Microsoft.AspNetCore.Html.IHtmlContent heading

    The heading for the section

    Microsoft.AspNetCore.Html.IHtmlContent leadingHtml

    Any HTML to output at the start of the section

    HtmlAttributes htmlAttributes

    Any HTML attributes to apply to the section container

    Returns
    Type Description
    Section<TModel>

    The nested form section

    Type Parameters
    Name Description
    TModel

    The view model type for the current view

    Examples

    @using (var s = f.BeginSection("Section heading")) { using (var ss = s.BeginSection(new HtmlString("<strong>Nested section heading</strong>"))) { @ss.FieldFor(m => m.FirstName) } }

    | Improve this Doc View Source

    BeginSection<TModel>(ISection<TModel>, Func<Object, IHtmlContent>, Func<Object, IHtmlContent>, HtmlAttributes)

    Creates a nested form section.

    Declaration
    public static Section<TModel> BeginSection<TModel>(this ISection<TModel> section, Func<dynamic, IHtmlContent> heading, Func<dynamic, IHtmlContent> leadingHtml, HtmlAttributes htmlAttributes = null)
    Parameters
    Type Name Description
    ISection<TModel> section

    The section the section is being created under

    System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> heading

    The heading for the section

    System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> leadingHtml

    Any HTML to output at the start of the section

    HtmlAttributes htmlAttributes

    Any HTML attributes to apply to the section container

    Returns
    Type Description
    Section<TModel>

    The nested form section

    Type Parameters
    Name Description
    TModel

    The view model type for the current view

    Examples

    @using (var s = f.BeginSection("Section heading")) { using (var ss = s.BeginSection(@<strong>Nested section heading</strong>, leadingHtml: <p>Leading html...</p>)) { @ss.FieldFor(m => m.FirstName) } }

    | Improve this Doc View Source

    BeginSection<TModel>(ISection<TModel>, String, IHtmlContent, HtmlAttributes)

    Creates a nested form section.

    Declaration
    public static Section<TModel> BeginSection<TModel>(this ISection<TModel> section, string heading = null, IHtmlContent leadingHtml = null, HtmlAttributes htmlAttributes = null)
    Parameters
    Type Name Description
    ISection<TModel> section

    The section the section is being created under

    System.String heading

    The heading for the section

    Microsoft.AspNetCore.Html.IHtmlContent leadingHtml

    Any HTML to output at the start of the section

    HtmlAttributes htmlAttributes

    Any HTML attributes to apply to the section container

    Returns
    Type Description
    Section<TModel>

    The nested form section

    Type Parameters
    Name Description
    TModel

    The view model type for the current view

    Examples

    @using (var s = f.BeginSection("Section heading")) { using (var ss = s.BeginSection("Nested section heading")) { @ss.FieldFor(m => m.FirstName) } }

    | Improve this Doc View Source

    BeginSection<TModel>(ISection<TModel>, String, Func<Object, IHtmlContent>, HtmlAttributes)

    Creates a nested form section.

    Declaration
    public static Section<TModel> BeginSection<TModel>(this ISection<TModel> section, string heading, Func<dynamic, IHtmlContent> leadingHtml, HtmlAttributes htmlAttributes = null)
    Parameters
    Type Name Description
    ISection<TModel> section

    The section the section is being created under

    System.String heading

    The heading for the section

    System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> leadingHtml

    Any HTML to output at the start of the section as a templated razor delegate

    HtmlAttributes htmlAttributes

    Any HTML attributes to apply to the section container

    Returns
    Type Description
    Section<TModel>

    The nested form section

    Type Parameters
    Name Description
    TModel

    The view model type for the current view

    Examples

    @using (var s = f.BeginSection("Section heading")) { using (var ss = s.BeginSection("Nested section heading", leadingHtml: @<p>Leading html...</p>)) { @ss.FieldFor(m => m.FirstName) } }

    | Improve this Doc View Source

    BeginSection<TModel>(IForm<TModel>, IHtmlContent, IHtmlContent, HtmlAttributes)

    Creates a top-level form section.

    Declaration
    public static Section<TModel> BeginSection<TModel>(this IForm<TModel> form, IHtmlContent heading, IHtmlContent leadingHtml = null, HtmlAttributes htmlAttributes = null)
    Parameters
    Type Name Description
    IForm<TModel> form

    The form the section is being created in

    Microsoft.AspNetCore.Html.IHtmlContent heading

    The heading for the section

    Microsoft.AspNetCore.Html.IHtmlContent leadingHtml

    Any HTML to output at the start of the section

    HtmlAttributes htmlAttributes

    Any HTML attributes to apply to the section container

    Returns
    Type Description
    Section<TModel>

    The form section

    Type Parameters
    Name Description
    TModel

    The view model type for the current view

    Examples

    @using (var s = f.BeginSection(new HtmlString("<strong>Section heading</strong>"))) { @s.FieldFor(m => m.FirstName) }

    | Improve this Doc View Source

    BeginSection<TModel>(IForm<TModel>, Func<Object, IHtmlContent>, Func<Object, IHtmlContent>, HtmlAttributes)

    Creates a top-level form section.

    Declaration
    public static Section<TModel> BeginSection<TModel>(this IForm<TModel> form, Func<dynamic, IHtmlContent> heading, Func<dynamic, IHtmlContent> leadingHtml, HtmlAttributes htmlAttributes = null)
    Parameters
    Type Name Description
    IForm<TModel> form

    The form the section is being created in

    System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> heading

    The heading for the section as a templated razor delegate

    System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> leadingHtml

    Any HTML to output at the start of the section as a templated razor delegate

    HtmlAttributes htmlAttributes

    Any HTML attributes to apply to the section container

    Returns
    Type Description
    Section<TModel>

    The form section

    Type Parameters
    Name Description
    TModel

    The view model type for the current view

    Examples

    @using (var s = f.BeginSection(@<strong>Section heading</strong>, leadingHtml: @<p>Leading html...</p>)) { @s.FieldFor(m => m.FirstName) }

    | Improve this Doc View Source

    BeginSection<TModel>(IForm<TModel>, String, IHtmlContent, HtmlAttributes)

    Creates a top-level form section.

    Declaration
    public static Section<TModel> BeginSection<TModel>(this IForm<TModel> form, string heading = null, IHtmlContent leadingHtml = null, HtmlAttributes htmlAttributes = null)
    Parameters
    Type Name Description
    IForm<TModel> form

    The form the section is being created in

    System.String heading

    The heading for the section

    Microsoft.AspNetCore.Html.IHtmlContent leadingHtml

    Any HTML to output at the start of the section

    HtmlAttributes htmlAttributes

    Any HTML attributes to apply to the section container

    Returns
    Type Description
    Section<TModel>

    The form section

    Type Parameters
    Name Description
    TModel

    The view model type for the current view

    Examples

    @using (var s = f.BeginSection("Section heading")) { @s.FieldFor(m => m.FirstName) }

    | Improve this Doc View Source

    BeginSection<TModel>(IForm<TModel>, String, Func<Object, IHtmlContent>, HtmlAttributes)

    Creates a top-level form section.

    Declaration
    public static Section<TModel> BeginSection<TModel>(this IForm<TModel> form, string heading, Func<dynamic, IHtmlContent> leadingHtml, HtmlAttributes htmlAttributes = null)
    Parameters
    Type Name Description
    IForm<TModel> form

    The form the section is being created in

    System.String heading

    The heading for the section

    System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> leadingHtml

    Any HTML to output at the start of the section as a templated razor delegate

    HtmlAttributes htmlAttributes

    Any HTML attributes to apply to the section container

    Returns
    Type Description
    Section<TModel>

    The form section

    Type Parameters
    Name Description
    TModel

    The view model type for the current view

    Examples

    @using (var s = f.BeginSection("Section heading", leadingHtml: @<p>Leading html...</p>)) { @s.FieldFor(m => m.FirstName) }

    | Improve this Doc View Source

    PartialForAsync<TModel, TPartialModel>(ISection<TModel>, Expression<Func<TModel, TPartialModel>>, String)

    Renders the given partial in the context of the given property. Use PartialFor(m => m) to render a partial for the model itself rather than a child property.

    Declaration
    public static Task<IHtmlContent> PartialForAsync<TModel, TPartialModel>(this ISection<TModel> section, Expression<Func<TModel, TPartialModel>> partialModelProperty, string partialViewName)
    Parameters
    Type Name Description
    ISection<TModel> section

    The current section

    System.Linq.Expressions.Expression<System.Func<TModel, TPartialModel>> partialModelProperty

    The property to use for the partial model

    System.String partialViewName

    The name of the partial view to render

    Returns
    Type Description
    System.Threading.Tasks.Task<Microsoft.AspNetCore.Html.IHtmlContent>

    The HTML for the rendered partial

    Type Parameters
    Name Description
    TModel

    The form model type

    TPartialModel

    The type of the model property to use for the partial model

    • Improve this Doc
    • View Source
    Back to top © Copyright 2012-2020 MRCollective, Rob Moore, Matt Davies and the contributors to ChameleonForms.