This project is read-only.

PrefixedId helper

Each helper  has associated with it a name prefix. The name prefix associated witha main View is an empty string, but the name prefixes associated with helpers of partial views, templates or returned after in-line transformations are not empty. The name prefix is added as a prefix to all input fields names, and since the id of all input fields are computed from their names, it indirectly affect also all ids.

If you need to refer to a an input field from some JavaScript code you needs to know its right id. You can compute it with the help fo the PrefixedId helper overloads:

 

public static string PrefixedId<VM>(this HtmlHelper<VM> htmlHelper, string localName)
public static string PrefixedId<VM,T>(this HtmlHelper<VM> htmlHelper, Expression<Func<VM, T>> expression)

 

You can pass to the PrefixedId helper either the name of the property or the Lambda Expression that univocally identify it.

Last edited Jun 22, 2014 at 11:56 AM by frankabbruzzese, version 4

Comments

No comments yet.