Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Issue: Add support for conditional attributes in the Html helpers [476]

$
0
0
Today, if a user puts the following in a CSHTML page:

@Html.TextBox("myname", "mytext", new { disabled = isDisabled })

this will render a "disabled" attribute whose value will be set to True or False. This is inconsistent with HTML's handling of boolean attributes, and it's also inconsistent with the work we did in Razor v2 to support conditional attributes in Razor markup.

This suggestion is to add conditional attribute logic to the Html helpers so the above would conditionally display the disabled attribute (provided that isDisabled is a boolean).
Comments: I think this should also handle null values as asked in [this StackOverflow question](http://stackoverflow.com/questions/16673903/inconsistent-null-attribute-handling-in-asp-net-mvc-4).

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>