我需要将@ html.label的值传递给变量" data"控制器" Verificar"点击按钮后。
我做了:
@Html.Label("modalTitle", new { id = "modalTitle" })
<button type="button" class="btn btn-defaultgreen" onclick="location.href = '@Url.Action("Verificar", "Feriado", new { date = @Html.Label("modalTitle", new { id = "modalTitle" }).toString() }, null)'">Create Event</button>
但不使用此方法....需要你的帮助!感谢
答案 0 :(得分:0)
更改日历功能以添加数据属性,以便根据标签将数据设置为数据属性:
$('#calendar').fullCalendar({
editable: false,
events: "/Reglamento/GetEvents/",
selectable:true,
select: function(start, end, jsEvent, view) {
//Bootstrap modal
$('#modalTitle').html(start.toString().substring(0, 15));
//Add data attribute - can have better date format here (e.g. yyyy-MM-dd)
$('#modalTitle').data("startdate", start.toString().substring(0, 15);
$('#fullCalModal').modal();
}
});
更新按钮以调用抓取数据属性的函数,构造网址并设置位置:
function NavigateByDate()
{
var date = $('#modalTitle').data("startdate");
//this could be done better...should show the intention though
var url = '@Url.Action("Verificar", "Feriado")' + '?data=' + date;
location.href = url;
}