This is a migrated thread and some comments may be shown as answers.

Problem on model data while doing [HttpPost]

1 Answer 36 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Neeraj
Top achievements
Rank 1
Neeraj asked on 03 Oct 2013, 10:02 AM
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

 @(Html.Kendo().TabStrip()
              .Name("assetTabStrip")
              .Items(assetTabStrip => assetTabStrip.Add().Text("Field Criteria")
                  .Selected(true)
                  .LoadContentFrom("EditFieldCriteria", "Asset", new { GroupID = Model.GroupID }))
              .Items(assetTabStrip => assetTabStrip.Add().Text("Sort Criteria")
                  .LoadContentFrom("EditSortCriteria", "Asset", new { GroupID = Model.GroupID }))

              .Animation(false)

              )

Partial view

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

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

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

</table>

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

groupModel.Criteria became null.

Please help.



1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 07 Oct 2013, 11:02 AM
Hello,

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.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TabStrip
Asked by
Neeraj
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or