-1

我一周前刚开始 MVC3,我现在被踩到了,我有一个预填充的下拉列表,但我想在 HTTPpost 之前或者最好每次有人在列表中选择不同的选项来显示它时获取下拉列表的选定值。

 @Html.DropDownList("MyList",(object)@ViewBag.chosen)
You have chosen (object)@ViewBag.chosen
4

1 回答 1

0

将此代码添加到您的 head 部分

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>

$(document).ready(function () {
      $("#MyList").on("change", function () {
          $("#MyList").after("You have chosen " + $("#MyList").val());
      });
  });
于 2013-01-05T07:13:27.207 回答