Question: How to pass values of partial view models on submit from another partial view


How to pass values of partial view models on submit from another partial view

Answers 1
Added at 2016-12-27 22:12

i have this viewmodel

    public class RHAPostModel
        public PostingMain PostMainData { get; set; }
        public List<MailingList> MailListData { get; set; }
        public List<MailingGroup> MailGroupData { get; set; }

This is my get action

    public ActionResult Index()
        var model = new RHAPostModel

                    MailListData = _dbrepo.GetDefaultRecipient().ToList(),
                    MailGroupData = _dbrepo.GetDefaultGroup().ToList()


        return View(model);


this is my view

<div class="col-md-3">
    @*side menu here*@


<div class="col-md-9" style="height:95%;">
    @*wysiwyg container here*@
    <div id="placeholder">
                    <div id="Postcover" class="text-center">

                            <div style="background-color:white;box-shadow: 10px 10px 5px #888888;width:75%;height:500px;padding:20px;border-radius:10px;">
                                Complete Message Post Information

                    <div id="RushPostWrapper" >



When I hit submit inside the doesn't pass the other modeldata. I'm new to partial views..I was able to pass them if not in partial views..but for proper and cleaner look I wanted to use partial.

this is the posting tool part

        @model RHA.RushPost.ViewModel.RHAPostModel

        @using (Html.BeginForm())

        <div style="margin-bottom:30px;">
    <!-- This will contain your HtmlContent and use the TinyMCE editor-->
            @Html.TextAreaFor(model => model.PostMainData.MessageContent, new { @id = "RushPostContent", @style = "margin:20px;" })

          @foreach (var x in Model.MailListData)
            @x.userEmail <<-- i use this for testing and value is passed
          @Html.HiddenFor(m => m.MailListData)

        <div class="text-right" style="margin-top:20px;">
         <button type="button" class="btn btn-primary" id="btnImageUpdate">UpdateImage</button>
        <button type="submit" class="btn btn-primary" id="btnSaveDraft" name="Command" value="Draft">Save as Draft</button>
        <button type="submit" class="btn btn-info" id="btnSaveTemplate" name="Command" value="Template">Save as Template</button>
        <button type="submit" class="btn btn-success" id="btnCampaign" name="Command" value="Send">Send Campaign</button>
        <button name="ClientCancel" class="btn btn-danger" type="button" onclick="document.location.href=$('#cancelUrl').attr('href');">Clear</button>


but on submit..everythin is null except for the messagecontent data. been searching..hard..

Answers to

How to pass values of partial view models on submit from another partial view

nr: #1 dodano: 2016-12-28 07:12

Hi, your partial view is accepting RHAPostModel but I can't see any RHAPostModel inside your view model ?

Source Show
◀ Wstecz