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 6805355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:34:35+00:00 2026-05-26T19:34:35+00:00

I am new to MVC and trying to implement what I would expect to

  • 0

I am new to MVC and trying to implement what I would expect to be a common problem. I have a simple search form that I want to implement on each page of the site. I want this section to maintain its own code so that I don’t have to duplicate it on each page.

So far I have been able to do this by calling a render action on the template page. The render action populates the quicksearch form. When I submit the form I am able to validate the form, however I have not found a way to redisplay the same page with the validation information. I would prefer a way that would just refresh the form area, but I would accept a full postback as long as the page is redisplayed.

Template Render Call

@{Html.RenderAction("Display", "QuickSearch");}

ActionController

    [HttpPost]
    public ActionResult Submit(QuickSearchModel qsModel)
    {
        if (!ModelState.IsValid)
        {
            return PartialView(qsModel);
        }

        //Perform redirect
    }

 [ChildActionOnly]
        public ActionResult Display()
        {
           //populate model
           return View(qsModel);
         }

Quick Search View

<div>
    @using (Html.BeginForm("Submit", "QuickSearch"))
    { 
        @Html.ValidationSummary(true)
        @Html.LabelFor(m => m.Destination)@Html.EditorFor(m => m.Destination)@Html.ValidationMessageFor(m => m.Destination)<br />
        @Html.LabelFor(m => m.ArrivalDate)@Html.EditorFor(m => m.ArrivalDate)@Html.ValidationMessageFor(m => m.ArrivalDate)
        @Html.LabelFor(m => m.DepartureDate)@Html.EditorFor(m => m.DepartureDate)@Html.ValidationMessageFor(m => m.DepartureDate)<br />
        @Html.LabelFor(m => m.Adults)@Html.DropDownListFor(model => model.Adults, new SelectList(Model.AdultsSelectOptions, "value", "text", Model.Adults))<br />
        @Html.LabelFor(m => m.Children)@Html.DropDownListFor(model => model.Children, new SelectList(Model.ChildrenSelectOptions, "value", "text", Model.Children))<br />
        <input id="qsSubmit" name="qsSubmit" type="submit" value="Submit" />
    }
</div>

Thanks in advance for any assistance!

  • 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-26T19:34:36+00:00Added an answer on May 26, 2026 at 7:34 pm

    I see that you have the following problems:

    1. How to redirect back to the page, from which the search was made?
    2. What if this original page was “POSTed to” – that is it was rendering something, based on POST request? In this case we will not
      be able to “re-produce” this POST in any easy way;
    3. After we have redirected to the original page, how to communicate the search model (or just it’s errors), which we have failed to
      validate?

    Given all these challenges, I would first seriously consider making this search form in AJAX style. That would be much easier solution, if it fits you.

    If AJAX is not an option I see following solutions to the respective questions:

    1. I would make a hidden field in the search form with the URL of original page. When validation fails, we can redirect to this URL (just check that it is local URL and no one tries to brake something);
    2. This is a major problem – trying to replay original POST is not easy, but it may not be needed either – just check if this is a problem anyway;
    3. You could use TempData dictionary to communicate errors or model back to original page.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement RedirectAttributes feature in Spring MVC 3.1-Release I'm sending simple form
I'm trying to implement a simple ActionLink that will delete records using ASP.NET MVC.
I am new to both MVC and Stackoverflow I am trying to implement pagination
I have a new asp.net mvc project and i am trying to figure out
I am trying to start a new project (asp.net MVC) and I would like
I'm new to Spring and Spring MVC. I'm trying to implement a basic web-application
I'm new to MVC and I'm trying to figure out how to implement business
I am new MVC user and I am trying to make shopping cart as
Basically what the title says. I created a new MVC application. I'm trying to
I'm new to MVC and Codeigniter and am trying to get a class working.

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.