RenderAction does not consider my validations in ASP.NET Models

0

RenderAction has stopped considering fields marked as [Required] in 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 that is being loaded with the 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 the 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");
}
    
asked by anonymous 08.02.2014 / 01:10

1 answer

0

The problem has been solved using javascript. It was poorly positioned on the page.

But one of the problems still persists!

The TinyMCE text editor when used on a page loaded by Render Action does not work, if I load it from the New page and load List with render action below it, it does not open the text editor. If I load it on a page alone, it works out of the box. If I load it on your own page using another Render Action it also crashes.

    
10.02.2014 / 18:05