If you've been working with ASP.NET MVC Preview 3, or later, you may have wondered how to create a readonly textbox control using the HtmlHelper class.
You can accomplish this using an anonymous object initializer with the property "ReadOnly" for the htmlAttributes parameter.
Here is an example:
Html.TextBox("UrlID", new {ReadOnly="ReadOnly"})
You can also specify other arguements for the rendered Html input control as part of the htmlAttributes parameter, just by including them in the anonymous object initializer.
Here are a few other examples to help you out:
new { _class="cssClass", onclick="alert('Alert!')" })
Subscribe to:
Post Comments (Atom)
3 comments:
This post is worthless without more sourcecode!!!
Harsh Antonio, harsh.
Actually, I found it to be exactly what I needed.
Thanks
Post a Comment