I am getting a missing ) after argument list in the chrome console. I don't understand why because it doesn't seem like there's missing one. I know it's not because of the string I'm passing because the string actually show how it's supposed to. so here's my code :
This is the HTML code:
<button class="btn btn-primary btn-lg" type="button" onclick="annuler(@ViewBag.id_dcr,@ViewBag.number)">
Annuler
</button>
This is the Javascript function :
function annuler(id_dcr, number)
{
window.location.href = ("/ModifyDocument/Index?id_dcr=" + id_dcr + "&number=" + number);
}
This is the C# method that pass the informations :
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();
}
This is the C# method definition that'll be call in the JavaScript function:
public ActionResult Index(int? id_dcr, string number)
annuler(@ViewBag.id_dcr,@ViewBag.number)if the values are string, they need to be wrapped in quotes.