Show / Hide Table of Contents

    Class HtmlHelperExtensions

    Extension methods against HtmlHelper.

    Inheritance
    System.Object
    HtmlHelperExtensions
    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
    Assembly: ChameleonForms.dll
    Syntax
    public static class HtmlHelperExtensions

    Methods

    | Improve this Doc View Source

    For<TModel>(IHtmlHelper, TModel, String)

    Creates a HTML helper based on another HTML helper against a different model type.

    Declaration
    public static DisposableHtmlHelper<TModel> For<TModel>(this IHtmlHelper htmlHelper, TModel model = null, string htmlFieldPrefix = null)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

    The original HTML helper

    TModel model

    An instance of the model type to use as the model

    System.String htmlFieldPrefix

    A prefix value to use for field names

    Returns
    Type Description
    DisposableHtmlHelper<TModel>

    The HTML helper against the other model type

    Type Parameters
    Name Description
    TModel

    The model type to create a helper for

    | Improve this Doc View Source

    For<TParentModel, TChildModel>(IHtmlHelper<TParentModel>, Expression<Func<TParentModel, TChildModel>>, Boolean)

    Creates a HTML helper from a parent model to use a sub-property as it's model.

    Declaration
    public static DisposableHtmlHelper<TChildModel> For<TParentModel, TChildModel>(this IHtmlHelper<TParentModel> helper, Expression<Func<TParentModel, TChildModel>> propertyFor, bool bindFieldsToParent)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TParentModel> helper

    The parent HTML helper

    System.Linq.Expressions.Expression<System.Func<TParentModel, TChildModel>> propertyFor

    The sub-property to use

    System.Boolean bindFieldsToParent

    Whether to set field names to bind to the parent model type (true) or the sub-property type (false)

    Returns
    Type Description
    DisposableHtmlHelper<TChildModel>

    A HTML helper against the sub-property

    Type Parameters
    Name Description
    TParentModel

    The model of the parent type

    TChildModel

    The model of the sub-property to use

    | Improve this Doc View Source

    GetChameleonForm<TModel>(IHtmlHelper<TModel>)

    Returns the current ChameleonForm that is in context for the view.

    Declaration
    public static IForm<TModel> GetChameleonForm<TModel>(this IHtmlHelper<TModel> helper)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> helper

    The current HTML helper

    Returns
    Type Description
    IForm<TModel>

    The ChameleonForms Form<TModel> instance

    Type Parameters
    Name Description
    TModel

    The page model type

    | Improve this Doc View Source

    GetChameleonFormsField<TModel>(IHtmlHelper<TModel>)

    Returns the current ChameleonForms form field that is in context for the view.

    Declaration
    public static Field<TModel> GetChameleonFormsField<TModel>(this IHtmlHelper<TModel> helper)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> helper

    The current HTML helper

    Returns
    Type Description
    Field<TModel>

    The ChameleonForms Field<TModel> instance

    Type Parameters
    Name Description
    TModel

    The page model type

    | Improve this Doc View Source

    GetChameleonFormsMessage<TModel>(IHtmlHelper<TModel>)

    Returns the current ChameleonForms message that is in context for the view.

    Declaration
    public static Message<TModel> GetChameleonFormsMessage<TModel>(this IHtmlHelper<TModel> helper)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> helper

    The current HTML helper

    Returns
    Type Description
    Message<TModel>

    The ChameleonForms Message<TModel> instance

    Type Parameters
    Name Description
    TModel

    The page model type

    | Improve this Doc View Source

    GetChameleonFormsNavigation<TModel>(IHtmlHelper<TModel>)

    Returns the current ChameleonForms navigation that is in context for the view.

    Declaration
    public static Navigation<TModel> GetChameleonFormsNavigation<TModel>(this IHtmlHelper<TModel> helper)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> helper

    The current HTML helper

    Returns
    Type Description
    Navigation<TModel>

    The ChameleonForms Navigation<TModel> instance

    Type Parameters
    Name Description
    TModel

    The page model type

    | Improve this Doc View Source

    GetChameleonFormsSection<TModel>(IHtmlHelper<TModel>)

    Returns the current ChameleonForms form section that is in context for the view.

    Declaration
    public static ISection<TModel> GetChameleonFormsSection<TModel>(this IHtmlHelper<TModel> helper)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> helper

    The current HTML helper

    Returns
    Type Description
    ISection<TModel>

    The ChameleonForms Section<TModel> instance

    Type Parameters
    Name Description
    TModel

    The page model type

    | Improve this Doc View Source

    GetDefaultFormTemplate(IHtmlHelper)

    Gets the registered default form template from RequestServices.

    Declaration
    public static IFormTemplate GetDefaultFormTemplate(this IHtmlHelper htmlHelper)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

    The HTML Helper

    Returns
    Type Description
    IFormTemplate

    An instance of the default IFormTemplate

    | Improve this Doc View Source

    GetFieldName<TModel, TResult>(IHtmlHelper<TModel>, Expression<Func<TModel, TResult>>)

    Returns the field name for a field in a view model.

    Declaration
    public static string GetFieldName<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> field)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> htmlHelper

    The HTML helper

    System.Linq.Expressions.Expression<System.Func<TModel, TResult>> field

    The field

    Returns
    Type Description
    System.String

    The field name

    Type Parameters
    Name Description
    TModel

    The view model type

    TResult

    The field type

    | Improve this Doc View Source

    GetFullHtmlFieldName<TModel, TResult>(IHtmlHelper<TModel>, Expression<Func<TModel, TResult>>)

    Returns the full HTML field name for a field in a view model within the current context / prefix.

    Declaration
    public static string GetFullHtmlFieldName<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> field)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> htmlHelper

    The HTML helper

    System.Linq.Expressions.Expression<System.Func<TModel, TResult>> field

    The field

    Returns
    Type Description
    System.String

    The full HTML field name

    Type Parameters
    Name Description
    TModel

    The view model type

    TResult

    The field type

    | Improve this Doc View Source

    IsInChameleonForm(IHtmlHelper)

    Returns whether or not the view is currently within the context of a ChameleonForms form. If this returns true then you can safely call GetChameleonForm<TModel>(IHtmlHelper<TModel>).

    Declaration
    public static bool IsInChameleonForm(this IHtmlHelper helper)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper helper

    The current HTML helper

    Returns
    Type Description
    System.Boolean

    Whether or not there is a ChameleonForms form in context

    | Improve this Doc View Source

    IsInChameleonFormsField(IHtmlHelper)

    Returns whether or not the view is currently within the context of a ChameleonForms form field. If this returns true then you can safely call GetChameleonFormsField<TModel>(IHtmlHelper<TModel>).

    Declaration
    public static bool IsInChameleonFormsField(this IHtmlHelper helper)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper helper

    The current HTML helper

    Returns
    Type Description
    System.Boolean

    Whether or not there is a ChameleonForms form field in context

    | Improve this Doc View Source

    IsInChameleonFormsMessage(IHtmlHelper)

    Returns whether or not the view is currently within the context of a ChameleonForms form message. If this returns true then you can safely call GetChameleonFormsMessage<TModel>(IHtmlHelper<TModel>).

    Declaration
    public static bool IsInChameleonFormsMessage(this IHtmlHelper helper)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper helper

    The current HTML helper

    Returns
    Type Description
    System.Boolean

    Whether or not there is a ChameleonForms form message in context

    | Improve this Doc View Source

    IsInChameleonFormsNavigation(IHtmlHelper)

    Returns whether or not the view is currently within the context of a ChameleonForms form navigation. If this returns true then you can safely call GetChameleonFormsNavigation<TModel>(IHtmlHelper<TModel>).

    Declaration
    public static bool IsInChameleonFormsNavigation(this IHtmlHelper helper)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper helper

    The current HTML helper

    Returns
    Type Description
    System.Boolean

    Whether or not there is a ChameleonForms form navigation in context

    | Improve this Doc View Source

    IsInChameleonFormsSection(IHtmlHelper)

    Returns whether or not the view is currently within the context of a ChameleonForms form section. If this returns true then you can safely call GetChameleonFormsSection<TModel>(IHtmlHelper<TModel>).

    Declaration
    public static bool IsInChameleonFormsSection(this IHtmlHelper helper)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper helper

    The current HTML helper

    Returns
    Type Description
    System.Boolean

    Whether or not there is a ChameleonForms form section in context

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