我需要获得下拉列表所选的值才能在相同的PartialView中使用它:
@Html.DropDownListFor(model => model.ModelType, new SelectList(Model.infoModel, "idModele", "nomModel"), new { id = "ModelType" })我需要ModelType的值来使用它,而不是2:
@Html.ActionLink("Order New", "View", new { id = 2 }, new { @class = "viewDialog" })我试过了,但没有成功,我希望有一种方法通过下拉值来更改2:
<input class="btn btn-primary" type="button" value="badd" id="badd">在我的文件末尾,我补充如下:
<script>
$('#badd').click(function (e) {
e.preventDefault();
window.location.replace =
'<%=Url.Action("Order New","View", "Home")%>' + '?id=' + $('#ModelType').val();
});
</script>发布于 2015-01-02 01:00:34
@Html.ActionLink("Order New", "View","Home",null, new { @id = "viewLink" })听听这个链接上的点击,读取下拉列表的选定值,构造url使用它来加载部分视图/导航到那个
$(function(){
$(document).on("click","#viewLink",function(e){
e.preventDefault();
var newUrl="@Url.Action("View","Home")?id="+$("#ModelType").val();
// you can do whatever you want with the new url
// window.location.href=newUrl;
});
});https://stackoverflow.com/questions/27736153
复制相似问题