Problem on model data while doing [HttpPost]

2 posts, 0 answers
  1. Neeraj
    Neeraj avatar
    1 posts
    Member since:
    Aug 2013

    Posted 03 Oct 2013 Link to this post

    Hi Team,

    We are having issues on Html.Kendo().TabStrip(). We are not able to pass our model to Html.Kendo().TabStrip(). There two issues on this.
    1. If i have partial view which is called in the TabStrip. If i have the data in the model still i am not able to pass it to the partial view.
    2. If i get the data in my partial view in the HttpPost the model data is becoming null.

    Sample code.

    Main View

                  .Items(assetTabStrip => assetTabStrip.Add().Text("Field Criteria")
                      .LoadContentFrom("EditFieldCriteria", "Asset", new { GroupID = Model.GroupID }))
                  .Items(assetTabStrip => assetTabStrip.Add().Text("Sort Criteria")
                      .LoadContentFrom("EditSortCriteria", "Asset", new { GroupID = Model.GroupID }))



    Partial view

    @model Sage.FA.SFAO.WebSite.Models.Asset.GroupModel
    @using EnumHtmlHelper.Helper
        ViewBag.Title = "EditFieldCriteria";

            <td align="left">@Html.Label("Look In:")</td>
            <td align="left">@Html.Label("Select an Operator:")</td>
            <td align="left">
                @Html.Label("Find What:")
         @foreach (var item in Model.Criteria) {
             if (item.LookIn != 0 && item.Operator != 0 && item.Value != null)
                                  @Html.EnumDropDownListFor(modelitem => item.LookIn)

                                  @Html.EnumDropDownListFor(modelitem => item.Operator)
                                @Html.TextBoxFor(modelitem => item.Value, new { @class = "k-textbox", @id = "expenseGL" })


    My Post method
            public ActionResult EditGroup(GroupModel groupModel, FormCollection formCollection)

    groupModel.Criteria became null.

    Please help.

  2. Daniel
    Daniel avatar
    2177 posts

    Posted 07 Oct 2013 Link to this post


    I am not sure if I understand correctly the issue with passing the data to the partial view, but because the tabs are configured to load the content via Ajax, you should add the data to the route values in order for it to be sent to the server with the request.
    As for posting the data - the input names should be in the format "CollectionParameterName[index].PropertyName" in order for the ModelBinder to be able to bind the collection. I would suggest to check this blog post which provides more detailed information on this matter.

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top