Can ASP.NET MVC generate elements with lower case name and id attributes -



Can ASP.NET MVC generate elements with lower case name and id attributes -

i hate asp.net html helpers generates name , id attributes in same case poco properties.

most developers typically utilize lower case values name , id cannot seem find way accomplish in asp.net mvc.

a through source shows there no way override functionality, wrong.

is @ possible?

edit: i'll more specific, examples of talking since there seems confusion.

my model looks this:

public class client { public string firstname { get; set; } public string lastname { get; set; } }

in view utilize html herlpers so:

@html.inputfor(m => m.firstname)

this generates markup looks this:

<input type="text" name="firstname" id="firstname" value="" />

i hate firstname property capitalized. in perfect world, way override generation of attribute value such can create "firstname" instead.

i not want alter poco property names lower case. much of asp.net mvc framework extensible , customizable - not?

display(name = "abc") attribute changes output of html.labelfor , when utilize editorformodel , displayformodel. not impact how html.textboxfor rendered , not supposed alter way id or name attributes of form fields rendered. if need have write own html helper like

public static mvchtmlstring lowertextboxfor<tmodel,tproperty>(this htmlhelper<tmodel> html, expression<func<tmodel,tproperty>> expr) { stringbuilder result = new stringbuilder(); tagbuilder tag = new tagbuilder("input"); tag.mergeattribute("type","text"); var lowerpropertyname = expressionhelper.getexpressiontext(expr).tolower(); tag.mergeattribute("name",lowerpropertyname); tag.mergeattribute("id",lowerpropertyname); result.append(tag.tostring()); homecoming new mvchtmlstring(result.tostring()); }

you can utilize html helper in view like.

@html.lowertextboxfor(x=>x.property1)

be aware illustration generate id , name attribute. have code other attributes unobtrusive attributes , other overloads of method utilize it

asp.net-mvc

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -