Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,


I'm fairly new to MVC 3 and i've come accorss a situation where i need to do something and i'm not sure of the best path. we have a set of topics related in a database with a parent-child relationship.


in a nutshell : -

1) user enters a string into search box, which is on every page, and clicks submit.
2) Ajax post to search controller which checks the reults of the search with 2 possible outcomes


2.1)IF we have more than one (parent) macth. the top ten parent matches are shown to the user, which results in the user choosing one (clicking a link) and and exact match so move on to 2.2


2.2) We have one exact match - a search for topics relating to this parent are queued and cached by the DB, we load the view and the results are returned Asynchronously by ajax when they are ready.
Posted
Comments
Jephunneh Malazarte 21-Sep-11 12:24pm    
were you using entity framework? just curious though.

1 solution

I will not give you solution but just showing you the path.

1. By understanding your scenario I will suggest you to use entity framework so it is easy to make request to database by parent child relationship.

2. You can generate links on the view page dynamically and attach those links with javascript function into which appropriate ids(dynamically fetched from database [parentids]) is passed as a parameter.

3. Into javascript function based on the parent id you can asynchronously request for next search result and update your page using ajax(jquery).

4. Also suggest to use JQuery which made your ajax request and dynamically page updation process simple.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900