0

I create a function of jquery that get the value from the select box, and then I assign the url of the current page to "http://localhost/Products?availability=High&priceSort=Low&tab=2" and I want to query the products in database by taking the parameter string of my url. Anyone know how can I take these parameter string to query in my controller using linq to sql and then I can get the result from database according to the value from URL.

I'm doing that with the filter box in the page of my view. I want to use the parameter string in my url to filter the products that I query from database.

Thanks.

1 Answer 1

1
public class ProductsController : Controller
{
    // http://localhost/Products/Search?availability=High&priceSort=Low&tab=2
    public ActionResult Search(string availability, string priceSort, int tab)
    {
        // your implementation here
    }
}
Sign up to request clarification or add additional context in comments.

4 Comments

Sorry, can you explain me clearly? because I'm just the beginner about that. Hope you not mind.
If you can update your question with more information about what you have so far, that would be helpful. I'm not quite sure what you're looking for at this point.
Query string parameters are automatically passed into corresponding method parameters of action methods. So if you have a query string paraeter of "availability" and an action method parameter named the same, that parameter will get its value from the query string.
Thanks for putting it so succinctly Phil. Hope the new job is treating you well! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.