Question

I would like to set the default value for an 'EditorFor' on my Shared Template, but only on the Crate method and not the Edit method. How would I do this?

Thanks,

Was it helpful?

Solution

I'm not exactly sure how you can do this other than setting an EditorFor template and using EditorFor for the Create method, and TextboxFor on the Edit method (or vice versa).

You can still extend TextboxFor with custom CSS if needed, but it will probably not be quite as pretty as EditorFor.

Another option would be to build a TextboxFor razor template (if you're using MVC3 and Razor) and load it in as a @helper { } (still passing the model).
see Scott Gu's post on this one

OTHER TIPS

At the end of the day I decided this should be done in the controller, on my Create/Edit actions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top