我得失踪了。我不明白为什么,因为它似乎没有丢失。我知道这不是因为我正在传递的字符串,因为字符串实际上显示了它应该如何。所以这是我的代码:
这是HTML代码:
<button class="btn btn-primary btn-lg" type="button" onclick="annuler(@ViewBag.id_dcr,@ViewBag.number)">
Annuler
</button>
这是Javascript函数:
function annuler(id_dcr, number)
{
window.location.href = ("/ModifyDocument/Index?id_dcr=" + id_dcr + "&number=" + number);
}
这是传递信息的C#方法:
public ActionResult Create(int? id_dcr, int? id_user, string number)
{
ViewBag.Documents = dbd.documents.Where(i => i.number == number).ToList();
ViewBag.id_dcr = id_dcr;
ViewBag.number = number;
return View();
}
这是将在JavaScript函数中调用的C#方法定义:
public ActionResult Index(int? id_dcr, string number)
答案 0 :(得分:1)
这应该解决它:
<button class="btn btn-primary btn-lg" type="button" onclick="annuler('@ViewBag.id_dcr','@ViewBag.number')">
Annuler
</button>