troubleshooting Question

Asp.NET Core post form from a layout page to a child page

Avatar of MRS
MRSFlag for United States of America asked on
* core mvcC#* Razor
3 Comments1 Solution158 ViewsLast Modified:
I an new to ASP.NET CORE Razor Pages & MVC, but very familiar with WebForms (so bear with me).  I am trying to create a web site using Razor Pages.  I have a layout pay that contains the main navbar and footer. In the navbar has simple search controls where a user can enter a 2 values, and click the search button.  I have a child page that handles the search (and also has more expanded search functionality)

How can go about passing the values from the layout page controls and redirecting them to the child page.  I have searched around and come up with this, but it doesn't seem to be working?  Am i way off base?

 @using (Html.BeginForm("~/v1/Agent/Search", "RemoteSearch", FormMethod.Post, new { @class = "form-inline my-2 my-lg-0" }))
                SearchModel searchModel = new SearchModel();
                @Html.DropDownListFor(x => searchModel.searchID, new SelectList(AccountSearch.GetSearches(), "searchID", "name"), htmlAttributes: new { @class = "form-control mr-sm-2" });
                @Html.TextBoxFor(x => searchModel.searchValue1, htmlAttributes: new { @class = "form-control mr-sm-2" });
                <button type="submit" class="btn btn-secondary my-2 my-sm-0">Search</button>
Ioannis Paraskevopoulos

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros