【发布时间】:2015-08-07 10:28:42
【问题描述】:
@Html.ActionLink("Search", "GetDateWiseGuestReport", "Reports", new { StartDate = "sss",EndDate="eee" }, new { @id = "btnDateWiseGuestSearch", @class = "btn btn-red" })
$("#btnDateWiseGuestSearch").bind('click', function () {
//Get the id of the selected item in dropdown
var EndDate = $("#txtDateWiseGuestEndDate").val();
var StartDate = $("#txtDateWiseGuestStartDate").val();
this.href = this.href.replace("sss", StartDate);
this.href = this.href.replace("eee", EndDate);
});
好的,我正在使用上面的代码在运行时更改操作链接 URL。一切运行顺利。但我有一个奇怪的问题,即当我第一次单击按钮时,它从文本框中获取值并相应更改,但是当我再次按下按钮时,它不会从文本框中获取新值,而是它以某种方式使用我输入的旧值第一次!
【问题讨论】:
-
考虑使用
.on('click')函数而不是绑定。 stackoverflow.com/questions/11847021/jquery-bind-vs-on
标签: javascript jquery asp.net-mvc asp.net-mvc-4 html.actionlink