Monday, 15 September 2014

C# ASP.NET MVC4 TextBoxFor-extension not replacing underscores with hyphens -


I have some type of overload for TextBoxFor-extension in my MVC4 application. The method looks like this:

  public static MvcHtmlString FormGroupTextBoxFor & LT; TModel, TProperty & gt; (MyHelper & lt; TModel & gt; myHelper, & lt; TModeel, TProperty & gt; & gt; expression, objection htmlAttributes = null of the function & lt; function)  

MyHelper Internally, there is an HtmlHelper-property used for "normal" MVC-accessories for which I do not have a surcharge.

In this method, I

  var route value decrease = new root values ​​(html property) {{"class", "form-control"}};  

Because I need to add some sections here

The next call is:

  var propertyInput = myHelper.HtmlInternal.TextBoxFor (Expression, Route Value Dict);  

which calls the default TextBoxFor () method.

When I call the extension

  @ My.FormGroupTextBoxFor (M => m.Name, new {@data_blur_update = "title", @data_blur_target_id = String.Format ("Vertical name {0}", eventID)})  

This rendered in HTML data_blur_update to Data-Blur-Update Why not change with?

What am I missing here?

I changed

  var Margololydict = new root value (html property ) {{"Class", "form-control"}};  

to

  var route value = HtmlHelper.AnonymousObjectToHtml property (html property); RouteValueDict.Add ("class", "form-control");  

Then insert the right attributes with hyphens instead of underscores which will


No comments:

Post a Comment