views:

30

answers:

2

I have 2 dropdown lists that I'm putting on to the page as follows. I can't get either to work:

<%=Html.DropDownList("CategoryId", Model.CategoryList, "Select a category to view")%>

and

<%=Html.DropDownList() For(m => m.SearchExpression) %>

What I need is to be able to redirect to a page when one of the items is selected and I click submit.

Can somebody please outline the steps I need to take to achieve this?

A: 

If your working in asp.net, you can put code in the SelectedIndexChanged event attached to the dropdown. Within this event, you can call Reponse.Redirect(url).

Marc
A: 
<% using( Html.BeginForm() ) { %>
     <%= Html.DropDownListFor( m => m.SearchExpression %>

     <input type="submit" value="Submit" />
<% } %>    

You will have a controller with a POST action:

[HttpPost]
public ActionResult Foo( ... )
{
    return RedirectToAction( ... );
    // OR return RedirectToRoute( ... );

}
Dismissile