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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:20:49+00:00 2026-05-16T05:20:49+00:00

I have a simple form based off a model called Visitor. I’d like to

  • 0

I have a simple form based off a model called Visitor. I’d like to have a search button by one of the id text fields so the user can click the button and have the page populate with visitor information: first name, last name, etc. In Web Forms I would do something like this:

page_load(){
    person = businessManager.FindPersonById(Convert.ToInt32(txtId.Text));
    txtFirstName.Text = person.FirstName;
    txtLastName.Text = person.LastName;
     ...
}

Prior to the search button, my view form called SignIn worked just fine; posted the data to the controller and did its thing:

    [HttpPost]
    public ActionResult SignIn(Visitor visitor) {
        if (ModelState.IsValid) {
            visitorRepoistory.Add(visitor);
            visitorRepoistory.Save();
            return RedirectToAction("/");
        } else {
            return View(new VisitorFormViewModel(visitor));
        }
    }

But now that I have a search button placed on my view form, I’m totally lost. I don’t know how to wire the search button to the controller so I can: 1.) Look up the data and 2.) Return it back to the sign in form to populate the fields. What are the steps I need to take to accomplish this?

Thanks.

  • 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-16T05:20:50+00:00Added an answer on May 16, 2026 at 5:20 am

    This question has been duplicated many times on SO

    Multiple forms in ASP.NET MVC

    But to answer your question you can have multiple forms on one page and have different Actions handle the submits. That’s what the link above outlines.

    Specific to your case:

    View

    <% Html.BeginForm("Search", "<ControllerName>"); %>
        Your search controls here
    <% Html.EndForm(); %>
    
    <% Html.BeginForm("SignIn", "<ControllerName>"); %>
        Your signin controls here
    <% Html.EndForm(); %>
    

    Controller

    [HttpPost]
    public ActionResult Search(FormCollection collection)
    {
       Do your search and return a view
    }
    
    [HttpPost]
    public ActionResult SignIn(Visitor visitor) 
    {
        if (ModelState.IsValid) {
            visitorRepoistory.Add(visitor);
            visitorRepoistory.Save();
            return RedirectToAction("/");
        } else {
            return View(new VisitorFormViewModel(visitor));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple form like this which accepts only two values string action and
Have a simple form (only extract fields here) but for some reason the JQserilization
I have a simple form that looks like this: <%= simple_form_for @study,:url => studies_path,
I have a simple form like this : <form method=post name=change_pass id=change_pass action=change_pass2.php> <input
I have a simple form that looks like so <% remote_form_for post, :url =>
My aim is to have a simple, form based CMS so the client can
I have a simple Zend-based form with reCaptcha element: $form = new Zend_Form(); $form->setName('forgotpassword')
So I have a really simple form on a website that's entirely AJAX based
There are some HTML based games (ie bootleggers.us) that have a simple login form
I have a simple jquery auto complete search in my Rails 3 app based

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.