.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Implementing search forms

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :ASP.Net


This should be pretty easy, but I'm struggling to think of the best way to implement a simple search form. I have a form with several fields in (such as textboxes, select lists, etc.). When the page first loads I need it to populate the select lists with records from a database and set some default values for a couple of textboxes. Then they click a search button and it displays a table of results. All very standard.

The problem is that because I'm using an HTTP GET to perform the search, I have to handle everything in one action method, and need to prevent the search from running when the page first loads. One way I was thinking of was:

public ViewResult Search(SearchViewModel viewModel)
    if (Request.Form["submitbutton"] != null) {
        SearchViewModel model = _searchService.GetSearch(viewModel);
        return View(model);
    return View();

But that feels wrong for some reason (especially passing a view model to get back another view model), plus I still need to populate parts of the view model for the select lists if the page is loading for the first time.

Maybe I'm over complicating things, but can anyone give me some guidance?


View Complete Post

More Related Resource Links

implementing a search similar to what you have in google when you type in a word


Dear all;

I have a textbox and what I would like to implement is basically a situation similar to what you have in google when you type in a word. In otherwords,

in the textbox when you type in J, it should generate a list of names that starts with O in alphabetical order, then next when you type in o, so that now you have Jo, it should generate a list of names instead that now starts with Jo in alphabetical order, then again when you type in h, it should generate a list of names that starts with Joh and so on. A sample code could be helpful. Thank you. No Javascript of Jquery please. All help will be greatly appreciated.

How to create a "search function" to find files and folders using C++ windows forms?

As mentioned above, how can I make a windows forms application that searches for files and folders specified by the user and display results in a ListBox? Thanks in advance another question: How can I make a textbox transparent? I would be really grateful if anybody told me what books are good to learn windows forms using C++? thanks again

Issue seen Implementing Search in WPF TreeView having both Virtualization and LoadOnDemand/Lazy load

We need to use Virualization and LoadonDemand for performance reasons. We are facing some issues in implenting a search Node capability. The issue has been described in detail by our Developer at the following link. A Sample code is also attached to the link below. http://social.msdn.microsoft.com/Forums/en/wpf/thread/ff5ab305-26f0-49a1-b1c8-3254e7edcd15

Implementing Internal Website Search ???


Hi all,

Iam working on internal Website search as user can search any thing in the website.

Now i dont have idea from where i can get start ?? how search will work .it should be whole database search or pages only???

Best Regards 

InfoPath forms library search returns no result on some records but not others


I have an Infopath forms library with about 500 forms in it.  When I search on the forms lbrary or the site that it's in, for the surname on the form (which is also promoted out as a column on the forms library) then I can find some forms, but not others.  The results are consistent.  So if I search for the name "Smith" I can find Smith's form, but if I search for "Jones" it always returns no results.  I have tried running a full crawl again, and also verified in the crawl log for the URL of the individual XML files for the forms for both "Smith" and "Jones".  Both forms are logged as being crawled successfully.  I am a site collection administrator and I can open both the forms and look at them.  The forms library has major versioning turned on and no content approval.

Any ideas on what might ber wrong?  Can anyone point me where to look?  We have one server for indexing and a separate one for queries (that also has Central Admin), plus two front end web servers.

Lars Nielsen http://discoverlars.wordpress.com

LINQ : Implementing IN and NOT IN

I got tried of typing

var result = from s in source
where items.Contains(s)
select s;and so I implemented the IN and NOT IN methods as extension methods:

Implementing Continuous Scrolling UI Pattern in ASP.NET

When you have numerous records to show, we have to resort to Paging. There is a better alternative to display voluminous data (especially read only data) while providing a better user experience & also making efficient use of server bandwidth - the Continuous Scrolling or Infinite Scrolling UI Pattern. Read on to know more about how to implement Continuous Scrolling UI Pattern in ASP.NET with a GridView.

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Routing for Web Forms in ASP.NET 4.0

posted a prototype demonstrating how one could use Routing within Web Forms. This is something you can do today with ASP.NET 3.5 SP1, because of the work we did to separate Routing from ASP.NET MVC. I would have liked to include Web Form Routing as part of the Routing feature when we were working on SP1, but we didn't have the time to do so in a robust manner before SP1 was locked down.

Application Architecture in Windows Forms 2.0

Applications have special support in Windows Forms. For starters, you can manage and tailor your application's lifetime, and, when the work flow is disrupted by an unhandled exception, you can choose from several methods of response. Then, there are several application models that you can employ, including Single Document Interface (SDI) and Multiple Document Interface (MDI) applications, each of which can support either multiple-instance or single-instance mode, the former the VS05 default and the latter requiring special consideration. All applications, however, can discover and use a wide variety of information about the system and environment they execute in.

Application Architecture in Windows Forms 2.0-Single-MDI Applications

Consider an MDI application like Microsoft Excel; files opened from the file system (by double-clicking) are all opened as separate child windows within the parent Excel window.7 For the first instance of an MDI application to open a new child window to display the file that was passed to the second instance of the application, the second instance must be able to communicate with the initial instance.

SharePoint Gets Search Analytics

Microsoft's SharePoint Portal Server 2003 was sold into a large number of organizations based solely on the strength of the search tool. Organizations hungered for a way to find the data they had generated.

Explained: Forms Authentication in ASP.NET

This module explains how forms authentication works in ASP.NET version 2.0. It explains how IIS and ASP.NET authentication work together, and it explains the role and operation of the FormsAuthenticationModule class.

Using Forms Authentication in ASP.NET - Part 1

Classic ASP developers often had to "roll their own" authentication scheme, however, in ASP.NET much of the grunt work has been taken out. This article outlines how things have changed and how FormsAuthentication can be used to secure a Web site with a minimal amount of code.

ASP.NET Forms Authentication - Part 1

Often, in legacy Web applications, users authenticate themselves via a Web form. This Web form submits the user's credentials to business logic that determines their authorization level. Upon successful authentication, the application then submits a ticket in the form of a cookie, albeit a hard cookie or session variable. This ticket contains anything from just a valid session identification access token to customized personalization values.

ASP.NET forms authentication with roles

.A timeout is specified in minutes. This is "time since last request" not the "time since login". If a login is indicated to be persistent (described later) this is ignored.
.A protection method is specified for the cookie.
Next I wanted to specify a folder to which access is restricted to people who have logged in. To do this I entered the following code in the web.config file (beneath

Forms Authentication in ASP.NET

In this tutorial you will learn about Forms Authentication in ASP.NET 2.0 - Forms Authentication class, Cookie Domain, Forms Cookies, The Login Control, Signin, Signout, Authenticate, Redirect, Login Status, Login Name and Login View Controls.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend