This project is read-only.

_D Helper

This control needs reference to MVCControlToolkit.Controls.Core-x.x.x.js.

The _D helper renders the field defined by expression with the formatting information provided in its FormatAttribute. In particular, if it is a number or a date it is globalized and displayed with the chosen format, or if null, with the NullDisplayText. The value so formatted is enclosed in a span tag whose id is computed as the one of all other Mvc helpers. It is able to do its job both on the server side and on the client-side when used within Client-Side templates.

Its complete signature is:


public static MvcHtmlString _D<VM, T>(
            this HtmlHelper<VM> htmlHelper, 
            Expression<Func<VM, T>> expression,
            IDictionary<string, object> htmlAttributes = null, 
            string valuesArrayName=null,
            string urlsArrayName=null)


The last two arguments are names of string arrays to be used to display enumerations and booleans. In case both of them are provided the last one specifies image urls representing the various values of the enumeration or boolean, while the other specifies the value for the alt attribute for the image tag. If just the valuesArrayName is provided the strings contained in this array will be used in place of images. The type bool? is dealt with as a three value enumeration {null, false, true}, while normal  booleans are delt with as two values enumerations {false, true}. 

String arrays are declared and given a name with the DeclareStringArray helper:


public static void DeclareStringArray(this HtmlHelper htmlHelper, string[] strings, string name)


Once declared string arrays can be used all over a View, included within the definition of Client-Side templates. Vice-versa, also string arrays declared within Client-Side templates are available all over the View.

Last edited Jun 22, 2014 at 11:55 AM by frankabbruzzese, version 9


No comments yet.