Join Now
|
Login
home
login
join now
.NET pattern framework
javascript + jquery patterns
database pattern framework
products and pricing
.NET design patterns
javascript design patterns
javascript tutorial
sql + database tutorial
connection strings
visual studio shortcuts
c# coding standards
html color codes
all references
explore
questions
ask question
tags
users
contact us
training courses
schedule
registration
about us
training and education for professional developers
login
join now
Home
Questions
Question
« Prev Topic
|
Next Topic »
Passing HTML Attributes into EditorFor in MVC 3
Bogusław Dobrogost
113
96.7
Jul 19, 2011
0
I want to pass a @class = attribute into one of my EditorFor() calls. Something like this:
<%= Html.EditorFor(model => model.Name,
new
{ @
class
=
"myclass"
}) %>
I cannot find an EditorFor() method signature that supports this.
This is a one-off so I don't want to dig deep and get into templates, etc.
How do I do this?
MVC 3
EditorFor
HTML Attributes
Add Comment
Flag
Follow
Email
2 answers
answer date
votes
comments
Rajesh Pillai
1,354
100.0
Jul 23, 2011
0
There is no overload for EditorFor that takes this kind of argument...
Alternate solution at
http://aspadvice.com/blogs/kiran/archive/2009/11/29/Adding-html-attributes-support-for-Templates-_2D00_-ASP.Net-MVC-2.0-Beta_2D00_1.aspx
Also check this alternative....
http://stackoverflow.com/questions/1625327/editorfor-and-html-properties
Hope this helps!
Add Comment
Flag
Link
King Wilder
568
99.9
Jul 24, 2011
0
Is there any reason you can't use TextBoxFor()? Or any of the other specific HTML Helpers? They have overloads for HTML attributes.
Add Comment
Flag
Link
Write Your Answer
return to top