2012-01-24 35 views
1

我認爲有此DropDownListDROPDOWNLIST的onchange動作

@Html.DropDownList("fOrderstatus", TryCast(ViewBag.StatusOptions, SelectList), "--pick--", New With { .title="Pick an orderstatus"}) 

該視圖顯示個PurchaseOrders和下拉列表應該給用戶過濾,例如可能性只選擇'主動'訂單。

我更喜歡普通香草ASP.NET MVC的解決方案。

在舊派ASP經典我會在選擇和被調用ASP的onchange=submit(通過形式進行)Request.Form([name of the SELECT]) ...

+0

我真的搜查無盡我的回答,也許我的最後一句話做到了:找到了答案myzelf 。首先,你需要定義表單: @using Html.BeginForm( 「指數」, 「個PurchaseOrder」) @ Html.DropDownList( 「fOrderstatus」,TryCast(ViewBag.StatusOptions,的SelectList),「--pick- - 」,新藉助{.title僞= 「選擇一個orderstatus」,.onchange = 「提交();」}) 結束使用 在收到所選擇的選項,所述控制器: 功能指數(BYVAL fOrderstatus作爲字符串)作爲ViewResult – Foxbox

+0

如果您發現答案很好,但不是評論,請創建一個正確答案並接受它。見http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/ – nemesv

回答

1

我真的搜查無盡我的回答,也許我的最後一句話做到了:myzelf找到了答案。首先,你需要定義表單:

@Using Html.BeginForm("index", "purchaseorders") 

    @Html.DropDownList("fOrderstatus", TryCast(ViewBag.StatusOptions, SelectList), "--pick--", New With { .title="Pick an orderstatus", .onchange="submit();"}) 

End Using 

在您收到所選擇的選項控制器:

Function Index(ByVal fOrderstatus As String) As ViewResult 
相關問題