This project is read-only.


WebFu is a collection of tools that assist in using MVC/MVP functionality to webforms in an unobtrusive manner. It aims to be modular so that the library can be used in whole or liberally copied in part.

This differs from a hybrid MVC/WebForms page in that you can use methods like UpdateModel() or TryValidateModel() in a WebForms Page class.

WebFu is moving to Visual Studio 2010 / .NET 4. Expect to see a WebFu NuGet package in the future.

See Getting Started for instructions on adding WebFu to your project.

  • jQuery 1.4.2+
Get jQuery here: Get JSON2 here:

See "Documentation" for specific scenarios. This project is currently in a PRE-RELEASE state. When work has been completed, a proper release will be provided as a download.

The features currently include:

HtmlHelper Methods

  • Supports basic lambda syntax such as Html.TextBoxFor(model => model.FirstName)
  • .Checkbox(), .CheckboxFor(), .DropDownList(), .DropDownListFor(), .RadioButton(), .RadioButtonFor(), .TextArea(), .TextAreaFor(), .ValidationMessageFor(), .LabelFor(), .HiddenFor(), .LabelFor(), .SpanFor()

Model Binding Support

Binding can be applied using value providers that implement IWFValueProvider. Built-in providers are available for ...
Simply call WFPageUtilities.UpdateModel() from anywhere in your code-behind, including [WebMethod]'s.

Support for Client and Server-Side Validation

Validation rules can be applied using rule providers that implement IWFRuleProvider (see WebFu Model Binding). Built-in providers are available for ... You can validate against the Model's own DataAnnotations or validate a given class against any other classes DataAnnotations where properties match (such as a "proxy class" for validation).
Built-in .net 3.5 DataAnnotations can be used such as [Required], [StringLength], [RegularExpression], and [Range].
  • XML validation configuration using WFXmlRuleSetProvider and WFUtilities.RegisterXMLValidationConfiguration()
WebFormsUtilities allows validation configuration via XML, including custom and client-side validators.

Validation can be invoked using both TryValidateModel() or WebForm's built-in validation using server tags provided under WebFormsUtilities.WebControls. Replace WebForms validation controls with the DataAnnotationValidatorControl and use the EnableClientValidationControl at the bottom of the form.
WebFormsUtilities has full support for globalization where display names (using a [Display] attribute) and error messages (via DataAnnotations or XML configuration) can be stored in project Resources. WebFormsUtilities mimics MVC2 and 3's validation model and custom validators need only implement ValidationAttribute and IWFClientValidatable.

Using Server Tags
Simply add a <DataAnnotationValidatorControl> for each of your server tag controls (ie: <asp:TextBox>) to apply all DataAnnotations validation to the server controls.
For client validation, add a <EnableClientValidationControl> tag.

Using TryValidateModel
Simply call WFPageUtilities.TryValidateModel() from anywhere in your code-behind. Using this method, validation can even be performed via AJAX calls from jQuery.
Enabling client validation can also be performed without the use of a server control by invoking WebFormsUtilities.WFPageUtilities.EnableClientValidation() at the end of your <form> tag in the markup using <% %> syntax.

Partial Views

Partial Views are supported in WebFu by the use of UserControls. UserControls treated as partial views retain the benefits of the Visual Studio IDE for editing markup and can still take advantage of code-behind, but must avoid using ViewState. UserControls can also share validation with the main page and are easy to bind to a View Model. See PartialViews for more information.

Unit Tested

HtmlTag and JSONObject Utilities

  • HtmlTag can be used to generate HTML or XML in an object-oriented manner and has handy methods like .Attr() which functions identical to jQuery's .attr() function. HtmlTag classes are used to generate HTML for the HtmlHelper methods. You can use similar syntax on the client-side with WFHtmlTag.js.
    //Illustrate generating HTML from JavaScript using WFHtmlTag.js

    function GenerateHTMLFromJS() {
        var div = webfu.HtmlTag("div", { "style": "background-color:Red;" });
        var span = webfu.HtmlTag("span")({ InnerText: "This HTML was created by WFHtmlTag.js" });
        span.Attr("style", "font-style:italic; font-weight: bold;");
        return div.Render();

    //Illustrate generating HTML from C# using HtmlTag.js
    string GenerateHTMLFromCS() {
        HtmlTag div = new HtmlTag("div", new { style = "background-color:Blue;" });
        HtmlTag span = new HtmlTag("span") { InnerText = "This HTML was created by HtmlTag.cs" };
        span.Attr("style", "font-style:italic; font-weight: bold;");
        return div.Render();

  • JSONObject is used to generate client validation JSON and can be used as an alternative to serialize data to JSON in .net 2.0.

Last edited Aug 14, 2013 at 3:20 AM by aikeru, version 17