Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7548891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:48:42+00:00 2026-05-30T09:48:42+00:00

I have a view with a couple of partial views that I bind to

  • 0

I have a view with a couple of partial views that I bind to my model. For some reason, when I post, the model is empty, and I am not sure why.

Below is my ViewModel.

public class IndexViewModel
{
    public bool AdvancedSearchOption { get; set; }
    public bool ForceAdvanced { get; set; }
    public bool ForceSimple { get; set; }
    public string SimpleSearchCriteria { get; set; }
    public string CustomerNumberCriteria { get; set; }
    public string AccountNumberCriteria { get; set; }
    public string NameCriteria { get; set; }
    public string PhoneNumberCriteria { get; set; }
}

Here is my controller. I am filling in all the values of the viewmodel because I wanted to see if the values got to the partial views. They do get there, so it is just on the post that I am having issues.

public class HomeController : Controller
{
    private ISecurityRepository SecurityRep;

    public HomeController(ISecurityRepository repo)
    {
        SecurityRep = repo;
    }

    public ActionResult Index()
    {
        IndexViewModel temp = new IndexViewModel();
        temp.AdvancedSearchOption = SecurityRep.DefaultToAdvancedSearch(User.Identity.Name);
        temp.ForceAdvanced = false;
        temp.ForceSimple = false;
        temp.SimpleSearchCriteria = "Testing";
        temp.AccountNumberCriteria = "Acct";
        temp.CustomerNumberCriteria = "Cust";
        temp.NameCriteria = "Name";
        temp.PhoneNumberCriteria = "Phone";
        return View(temp);
    }

    public ActionResult SimpleSearch()
    {
        IndexViewModel temp = new IndexViewModel();
        temp.AdvancedSearchOption = SecurityRep.DefaultToAdvancedSearch(User.Identity.Name);
        temp.ForceAdvanced = false;
        temp.ForceSimple = true;
        temp.SimpleSearchCriteria = "Testing";
        temp.AccountNumberCriteria = "Acct";
        temp.CustomerNumberCriteria = "Cust";
        temp.NameCriteria = "Name";
        temp.PhoneNumberCriteria = "Phone";
        return View("Index",temp);
    }

    public ActionResult AdvancedSearch()
    {
        IndexViewModel temp = new IndexViewModel();
        temp.AdvancedSearchOption = SecurityRep.DefaultToAdvancedSearch(User.Identity.Name);
        temp.ForceAdvanced = true;
        temp.ForceSimple = false;
        temp.SimpleSearchCriteria = "Testing";
        temp.AccountNumberCriteria= "Acct";
        temp.CustomerNumberCriteria= "Cust";
        temp.NameCriteria= "Name";
        temp.PhoneNumberCriteria = "Phone";
        return View("Index", temp);
    }

    [HttpPost]
    public ActionResult Index(IndexViewModel vm, FormCollection formCollection)
    {
        return View();
    }
}

Here is my view

@model TRIOSoftware.Magnum.Models.IndexViewModel

@{
    ViewBag.Title = "Search";
}

@if ((@Model.AdvancedSearchOption && @Model.ForceSimple != true) || @Model.ForceAdvanced == true)
{
    @Html.Partial("AdvancedSearch")
}
else
{
    @Html.Partial("SimpleSearch")
}

Here is my SimpleSearch partial view. I think if I can get this one working, the other will follow the same path. I do the post in the partial and I use jQuery to do it. I am not sure if either of these things could cause me issues or not. I only have all the hidden items in there because I didn’t know if not having them was causing my issues.

 @model TRIOSoftware.Magnum.Models.IndexViewModel

 <script type="text/javascript">
     $(document).ready(function () {
         $("#DefaultDiv").find("#DefaultAdvanced").click(function () {
             $.post("DefaultSimple");
         });

         $("#SearchSection").find("#SearchButton").click(function () {
             $.post("");
         });
     });
</script>

 @using (Html.BeginForm("Index","Home"))
 {
     @Html.HiddenFor(m => m.ForceAdvanced)
     @Html.HiddenFor(m => m.AdvancedSearchOption)
     @Html.HiddenFor(m => m.ForceSimple)
     @Html.HiddenFor(m => m.AccountNumberCriteria)
     @Html.HiddenFor(m => m.CustomerNumberCriteria)
     @Html.HiddenFor(m => m.NameCriteria)
     @Html.HiddenFor(m => m.PhoneNumberCriteria)

     <div id="DefaultDiv" style="float:right">
         <a id="DefaultAdvanced" href="#" class="ButtonClass">Default Simple Search</a>
     </div>

     <div style="clear:both; margin: auto; width: 800px">
         <img src="../../Content/images/TRIO_transparent_image.gif"; alt="TRIO Software"; style="margin-left:150px; clear:left"/>
             <div style="clear:left; float: left" class="SearchText">
                  @Html.Label("What's your inquiry?:")
                  @Html.EditorFor(m => m.SimpleSearchCriteria, new { style = "width: 400px" })
             </div>
             <div id="SearchSection" style="float: left" class="SearchText">
                 <a href="#"; id="SearchButton" class="ButtonClass"><img src="../../Content/images/Search.gif"; alt="Search"; style="float:left" /></a>
             </div>
             <p style="clear:left;margin-left:400px">
                 @Html.ActionLink("Advanced Search", "AdvancedSearch", null, new { style = "clear:left" })
             </p>

    </div>
 }

Here is the HTML code when viewing the simple search partial view:

<div id="main">
    <script type="text/javascript">
        $(document).ready(function () {
            $("#DefaultDiv").find("#DefaultAdvanced").click(function () {
                $.post("DefaultSimple");
            });

            $("#SearchSection").find("#SearchButton").click(function () {
                $.post("");
            });
        });
    </script>

    <form method="post" action="/">
        <input type="hidden" value="False" name="ForceAdvanced" id="ForceAdvanced" data-val-required="The ForceAdvanced field is required." data-val="true">
        <input type="hidden" value="False" name="AdvancedSearchOption" id="AdvancedSearchOption" data-val-required="The AdvancedSearchOption field is required." data-val="true">
        <input type="hidden" value="False" name="ForceSimple" id="ForceSimple" data-val-required="The ForceSimple field is required." data-val="true">
        <input type="hidden" value="Acct" name="AccountNumberCriteria" id="AccountNumberCriteria">
        <input type="hidden" value="Cust" name="CustomerNumberCriteria" id="CustomerNumberCriteria">
        <input type="hidden" value="Name" name="NameCriteria" id="NameCriteria">
        <input type="hidden" value="Phone" name="PhoneNumberCriteria" id="PhoneNumberCriteria">
        <div style="float:right" id="DefaultDiv">
            <a class="ButtonClass ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" href="#" id="DefaultAdvanced" role="button"><span class="ui-button-text">Default Simple Search</span></a>
        </div>
        <div style="clear:both; margin: auto; width: 800px">
            <img style="margin-left:150px; clear:left" alt="TRIO Software" ;="" src="../../Content/images/TRIO_transparent_image.gif">
            <div class="SearchText" style="clear:left; float: left">
               <label for="What_s_your_inquiry_:">What's your inquiry?:</label>
               <input type="text" value="Testing" name="SimpleSearchCriteria" id="SimpleSearchCriteria" class="text-box single-line">
            </div>
            <div class="SearchText" style="float: left" id="SearchSection">
                <a class="ButtonClass ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="SearchButton" ;="" href="#" role="button"><span class="ui-button-text"><img style="float:left" alt="Search" ;="" src="../../Content/images/Search.gif"></span></a>
            </div>
            <p style="clear:left;margin-left:400px">
                <a style="clear:left" href="/Home/AdvancedSearch">Advanced Search</a>
            </p>
     </div>
    </form>
</div>

How do I fix this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:48:44+00:00Added an answer on May 30, 2026 at 9:48 am

    I had tried explicitly sending in the model to the partials with no luck. I believe that the partial views get the parent model by default if nothing is specified, so all I needed to do was to specify the model type in my partials, and I got the information.

    I finally figured it out with a lot of trial and error. My issue was being caused by me trying to use jQuery to do a post. There must be some other things you need to do to update your model doing it this way. Once I changed it out and put an input control on the form for the post, I got all my data back from the parent and partial view in the controller.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view model with a couple of properties that are not displaying
I have a view with datepicker control on it and couple of partial views
I have a view partial nameplate.jade that has a couple attributes bound from a
I have a view model that needs to encapsulate a couple of many-to-many relationships.
I have an Asp.net MVC partial view that is used for searching. It does
I have a View that has a single TextBox and a couple Button s
I have a list view which has a couple of views within it, I
I have a programmatically created UIToolbar in a couple of views. In my view
I have a view with couple of data templates in the resources of that
In my app, I have a table view controller that creates a couple of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.