2012-08-06 119 views
0

我使用DropDownListFor和我的網頁上的標籤文本。更改標籤更改DropDownListFor值

<%=Html.DropDownListFor(x => x.MotiveClientType, 
         new SelectList(
          Model.ClientMotives, "Id", "Label", Model.MotiveClientType), 
         new { id = "ddlMotiveClientType" } 
)%>      

如何在我的DropDownListFor上選擇值時更改我的標籤?

+0

你的意思是你想改變下拉標籤onclick? – Yasser 2012-08-06 12:29:40

回答

1

我不知道任何本地ASP.NET MVC的功能,這將允許你這樣做,但用jQuery來做是一件相當平凡的事情。下面是一個事件處理程序掛接到下拉&然後設置標籤文本的變化情況的一個例子:

$("#DropDownID").change(function() { 
    $("#LabelID").text("Your text here"); 
}); 

就有關值替換的ID。