2011-01-23 16 views
0
@using (Html.BeginForm("Index", "Bill")) 
{ 
    @Html.Label("FromDate") 
    @Html.DropDownList("FromDate",Model.DateList) 
    @Html.Label("ToDate") 
    @Html.DropDownList("ToDate", Model.DateList) 
    @Html.ActionLink("Filter", "Index", "Bill")   // I want to post to Index 
} 

    [HttpPost] 
    public ActionResult Index(string fromDate, string toDate) 
    { 
     //Process 
    } 

將日期範圍發佈到索引操作的正確方法是什麼?ASP.NET MVC:如何發佈下拉框的值來操作?

我需要指定哪種類型的URL?

我感謝您的回答。

回答

1

您的@Html.ActionLink("Filter", "Index", "Bill")只是一個錨標籤。你需要有一個提交按鈕:

<input type="Submit" /> 

我認爲是所有你需要提交您2倍的值。提交按鈕使用在您的Html.BeginForm()

中自動指定的 POST方法