I'm trying to apply a Style to the Editor for an element, but I can't make it work; what am I doing wrong?
@Html.EditorFor(model => model.ClienteNuevo)
@Html.ValidationMessageFor(model => model.ClienteNuevo,"" ,new Dictionary<string, string> { { "style", "width:500px" } })
Editor Style is a theme feature introduced with Version 3.0. This feature allows you to link a custom stylesheet file to the TinyMCE editor within the post edit screen.
Add new styles to the "Styles" dropdown in the What You See Is What You Get (WYSIWYG) toolbar, which are then also used for the "Class" dropdown available when inserting links, images, and media on pages. These styles can be block-level or span-level.
Gutenberg editor doesn't have its own styling options. The only way to change the appearance of the page is to change the template of the whole website. JetStyleManager is a Gutenberg block styles plugin that adds the design customization block for JetPlugins that work with Gutenberg.
Since MVC 5.1, you can pass in custom attributes with using the htmlAttributes
as a key:
@Html.EditorFor(model => model.ClienteNuevo,
new { htmlAttributes = new { @class = "form-control" } })
In older MVC versions there is no way to add html attributes with the EditorFor
method.
You should create a custom editor template or use Html.TextboxFor
istead of EditorFor
. You should check these topics topic1, topic2.
You can create own css class and appendd it to your editor:
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "custom-editor" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With