Solved

C# MVC4 views - including a search page

Posted on 2013-01-08
6
160 Views
Last Modified: 2013-01-22
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
Comment
Question by:sej69
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
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
 

Author Comment

by:sej69
Comment Utility
So the term I need to search on is "partial view".  I'll dig into that; thanks.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:sej69
Comment Utility
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
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
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
 

Author Closing Comment

by:sej69
Comment Utility
Led me down the right path to solve my problem. Thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now