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

     @(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.



  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 07 Oct 2013 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top