Getting Started


Add a reference to Build.Mvc.dll

From the Nuget Package Manager Console, you can type this command:

PM> Install-Package Build.Mvc5

Just add Build.Mvc.Html to your namespace imports in the web.config

<system.web.webPages.razor>
    <pages>
        <namespaces>
            <add namespace="Build.Mvc.Html" />
        </namespaces>
    </pages>
</system.web.webPages.razor>

TIP: There's a web.config in the root of each of your view folders!

Using Build.Mvc


Add the method prefix "Build" to something like this

@Html.ActionLink("Cancel", "Index", "Home", null, new { data_icon = "arrow-l", data_rel = "back" })

Then you can do this

@( Html.BuildActionLink("Cancel", "Index", "Home").
                Data("icon", "arrow-l").
                Data("rel", "back"))

Currently Supported Helpers

View a list of Common Methods for all Build extensions or other Tips for using Build.Mvc

  1. ActionLink
  2. TextBox
  3. CheckBox
  4. RadioButton
  5. DropDownList
  6. Label
  7. Hidden
  8. Form
  9. ValidationSummary
  10. ValidationMessage
  11. Button
  12. BuildTag

Extending Build.Mvc

Build MVC can easily be extended... just add your own extensions!

/// <summary>
/// This would add an Email() method which sets the type, placeholder text and tooltip
/// </summary>
public static TBuilder Email<TBuilder>(this TBuilder instance)
    where TBuilder : ITextBoxBuilder
{
    return instance.Attr("type", "email").
        Placeholder("yourname@your.com").
        Tooltip("Enter your email");
}

Or in VB.NET

''' <summary>
''' This would add an Email() method which sets the type, placeholder text and tooltip
''' </summary>
<Extension()>
Public Function Email(Of TBuilder As ITextBoxBuilder)(instance As TBuilder) As TBuilder
    Return instance.Attr("type", "email").
        Placeholder("yourname@your.com").
        Tooltip("Enter your email")
End Function

Last edited Jan 15, 2014 at 9:15 PM by grcodemonkey, version 52

Comments

No comments yet.