0
Renderaction stopped considering the fields marked as [Required]
on my models.
Example of one of the models:
private uint IdNews { get; set; }
[Required(ErrorMessage = "Defina o título.")]
public string Title { get; set; }
[UIHint("tinymce_jquery_full"), AllowHtml]
[Required(ErrorMessage = "Escreva a descrição.")]
public string Description { get; set; }
//[RegularExpression(@"^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$", ErrorMessage = "A data é inválida.")]
[Required(ErrorMessage = "Selecione a data de postagem.")]
public DateTime PostDate { get; set; }
[Required(ErrorMessage = "Escreva o nome do Administrador que esta postando.")]
public Admin AdminName { get; set; }
public Image Photo { get; set; }
This is the view being loaded with Hrml.Renderaction:
@model BraveryBranded.ASP.Models.News
@{
ViewBag.Title = "Adicionar";
}
<h2>@ViewBag.Title</h2>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Nova Notícia</legend>
<div class="editor-label">
<h3>*Título</h3>
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Title)
@Html.ValidationMessageFor(model => model.Title)
</div>
<div class="editor-label">
<h4>Imagem</h4>
</div>
<div class="editor-field">
<input type="file" id="file"/>
</div>
<div class="editor-label">
<h4>*Descrição:</h4>
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Description)
@Html.ValidationMessageFor(model => model.Description)
</div>
<br/>
<p>
<button class="btn btn-primary" type="submit">Adicionar</button>
</p>
</fieldset>
}
@*<div>
@Html.ActionLink("Back to List", "Index")
</div>*@
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
View where Renderactions are loaded:
@using BraveryBranded.ASP.Models
@model IEnumerable<BraveryBranded.ASP.Models.News>
@{
ViewBag.Title = "Notícias";
}
<h2>@ViewBag.Title</h2>
@{
Html.RenderAction("New", "News");
}
<hr/>
@{
Html.RenderAction("List", "News");
}
Luiz, at the end of your view
New
has a section for scripts. Copy it whole for theIndex
. Then we will see the question of the text editor.– Andre Calil
@Andrecalil did this and has not changed, only the validation fields are working, but the text editor that has not changed anything.
– Luiz Negrini
The editor works normally on the isolated page?
– Andre Calil
@Andrecalil Sim
– Luiz Negrini
@Andrecalil One thing I noticed is the size of it, when it opens on the isolated page, it has plenty of space to use the configured size (which is still the default). But I don’t know how to diminish it, I’m a beginner in .net... Does that have to do with?
– Luiz Negrini
I don’t think so man, what it looks like is that some script is missing for it. When you added Tinymce, did you follow any tutorial? Link here for me to see, please.
– Andre Calil
@Andrecalil It was here: http://www.tugberkugurlu.com/archive/tinymce-html-text-editior-and-asp-net-mvc-setting-it-up-has-become-easy-with-nuget
– Luiz Negrini
@Andrecalil is giving this error in jquery: Uncaught Typeerror: Object [Object Object] has no method 'tinymce' News:135 (Anonymous Function) News:135 fire jquery-1.10.2.js:3048 self.fireWith jquery-1.10.2.js:3160 jQuery.extend.ready jquery-1.10.2.js:433
 completed;
– Luiz Negrini
Exactly, some script is missing. I read the tutorial on top but found nothing. You added reference to some script that configured Tiny?
– Andre Calil
@Andrecalil I did not modify anything because it came out working right away, and still works on the page when it is alone. This this strange!
– Luiz Negrini
@Luiznegrini When you save the model with all blank fields, what happens?
– Leonel Sanches da Silva
@Gypsy.
– Luiz Negrini