Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding additional attributes to "EditorFor" control #78

Closed
mossywossy opened this issue Mar 2, 2013 · 2 comments
Closed

adding additional attributes to "EditorFor" control #78

mossywossy opened this issue Mar 2, 2013 · 2 comments

Comments

@mossywossy
Copy link

Hi,
I am migrating an old MVC razor project to use Bootstrap and have been finding this solution to the task great.
However, I have been trying to add additional attributes to an input control for a DateTime property type. I would typically do this as follows:

@html.EditorFor(model => model.DateTimeFrom, new { Attribute1 = "valueOfAttribute1"})

This is not working. The attribute isn't rendered at all in the resulting page. I believe this is down to this Bootstrap for MVC solution. Is it? Or am I using it incorrectly?

Kind regards.

Tomas

@erichexter
Copy link
Owner

Either override the editor templates.. here is a walkthrough of how to do
it
http://blogs.msdn.com/b/nunos/archive/2010/02/08/quick-tips-about-asp-net-mvc-editor-templates.aspxthis
shows webforms view engine, but it is identical with razor
or
use the uihint attribute to force that property to use a special editor
template.

http://digitaltoolfactory.net/blog/2012/04/how-to-use-ui-hints-and-display-templates-in-asp-net-mvc-3/

@mossywossy
Copy link
Author

Hi Eric! Thanks!

Cringe :-( ... I feel bad posting this as an issue after now realising that it was more down to my lack of knowledge of MVC and Editor Templates and therefore nothing to do with how Bootstrap for MVC4 operates per se.

Thanks again for the help.

Tomás

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants