0

I'm using two models:

public partial class FORUMTHREAD
{
    public FORUMTHREAD()
    {
        this.FORUMCATEGORY = new HashSet<FORUMCATEGORY>();
        this.FORUMPOST = new HashSet<FORUMPOST>();
    }

    public int TH_ID { get; set; }
    public System.DateTime DATE { get; set; }
    public string TOPIC { get; set; }
    public string USER { get; set; }

    public virtual ICollection<FORUMCATEGORY> FORUMCATEGORY { get; set; }
    public virtual ICollection<FORUMPOST> FORUMPOST { get; set; }      

}
}

public partial class FORUMPOST
{
    public FORUMPOST()
    {
        this.FORUMTHREAD = new HashSet<FORUMTHREAD>();
    }

    public int PO_ID { get; set; }
    public System.DateTime DATE { get; set; }
    public string POST { get; set; }
    public string USER { get; set; }

    public virtual ICollection<FORUMTHREAD> FORUMTHREAD { get; set; }
}
}

I have created view for Create function:

@model AnimeWeb.Models.FORUMTHREAD

@{
ViewBag.Title = "Create";
}

<h2>New Thread</h2>

@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)

<fieldset>

    <div class="editor-field">
        @Html.HiddenFor(model => model.TH_ID)
    </div>

    <div class="editor-label">
        TOPIC
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.TOPIC)
        @Html.ValidationMessageFor(model => model.TOPIC)
    </div>
    <div class="editor-label">
        CATEGORY
    </div>
    <div class="editor-field">
        @Html.DropDownList("Category", Model.GetCategories())
    </div>
    <div class="editor-label">
        POST
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.FORUMPOST)
        @Html.ValidationMessageFor(model => model.FORUMPOST)
    </div>
    <p>
        <input type="submit" value="Create" />
    </p>
</fieldset>
}

After that I created FORUMPOST.cshtml as partialview in folder Shared/EditorTemplates

@model AnimeWeb.Models.FORUMPOST

@Html.HiddenFor(model => model.PO_ID)
@Html.HiddenFor(model => model.USER)
<div>
    @Html.TextAreaFor(model => model.POST)
</div>

And the Partial View for FORUMPOST is not rendered. I have no idea what is wrong. I'm using other display/editor templates and those are working fine.

EDIT:

I have also GENRES EditorTemple which works.

GENRES.cshtml

@model AnimeWeb.Models.GENRES

@Html.HiddenFor(model => model.ID_GE)
@Html.HiddenFor(model => model.GENRE)
<table>
<tr>
    <td>
        @Html.EditorFor(model => model.isSelected)
    </td>
    <td>
        @Html.LabelFor(model => model.isSelected, Model.GENRE)
    </td>
</tr>

When I render it with @Html.EditorFor(model => model.GENRES) it is correctly displayed. I don't want to spam other controllers so you can refer to my old topic here

Community
  • 1
  • 1
Placek
  • 699
  • 2
  • 7
  • 10
  • I have other Editor template GENRES.cshtml, I also invoke it with @Html.EditorFor(model => model.GENRES) and it works. So i'm not sure @Html.Partial is necessary. – Placek Jan 23 '14 at 11:36
  • Which template is rendered? The default one? Maybe you have some different template in `~/Views/SomeController/EditorTemplates/FORUMPOST.cshtml`. – Darin Dimitrov Jan 23 '14 at 12:56

0 Answers0