Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

C# MVC4 views - including a search page

VS2012, c#

I apologize, I've been doing desktop apps with C# and haven't given web apps much of a thought until now so I'm learning and very much green.  I'm not sure of the terminology I need to search on so sorry for the simple question.

I've got a basic site in development with a model, view, and controller that functions.  Now, instead of the view dumping all the lines from the DB I want to add a search functionality into it.  Do I create the search boxes in the view or do I create another view and link it into the current view?  If the latter is the case, how do I link the external view into the current one?

Thanks for your help!
0
sej69
Asked:
sej69
  • 3
  • 3
1 Solution
 
Bob LearnedCommented:
The correct choice really depends on you.  How would you like it to function?  I have a page with a search box in a partial view that is rendered on the _Layout.cshtml page.
0
 
sej69Author Commented:
So the term I need to search on is "partial view".  I'll dig into that; thanks.
0
 
Bob LearnedCommented:
I found the _SearchPartial page:

 using (Html.BeginForm("SearchResults", "Shared"))
    { 
        <div class="searchContainer">
            @(this.Select("searchOption")
                .Class("sltSearch")
                .Options(@Model.Header.CustomerSearchOptionList)
              )
            <input name="searchCriteria" type="text" class="fldSearch" />
            @(this.SubmitButton("")
                .Class("btnSearch")
             )
        </div>
    }

Open in new window


When the page posts back, there is a SearchResults method on the SharedController.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
sej69Author Commented:
LearnedOne, is that custom coded or is that code generated for you?  I have a lot of files that were pre-generated but nothing called shared...
0
 
Bob LearnedCommented:
What controllers do you have?  That is a class that I created myself.  The decision on my side was to have a single controller called Shared.  You would just need the Action method and the Controller as arguments for the Html.BeginForm (Action, Controller).
0
 
sej69Author Commented:
Led me down the right path to solve my problem. Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now