jquery - access to javascript var from actionlink -
in page have following script:
<script language="javascript"> var needtoconfirm = true; window.onbeforeunload = confirmexit; function confirmexit() { if (needtoconfirm) { return "you have attempted leave page. " + "if have made changes fields without clicking save button, changes lost." + " wish proceed?"; } } </script> i able set needtoconfirm value in button this:
<input type="submit" value="save" name="_submitbutton" onclick="needtoconfirm = false"/> i want know if there's similar way in actionlink one:
@html.actionlink("remove item", "removeitemedit", new { @_cardid = model.mpacktoedit.mlistcardpack[i].mcard.mmastercard.mcardid, needtoconfirm = false }) i've tried doesn't work.
the third parameter of actionlink route values. need put needtoconfirm in fourth parameter - htmlattributes. try this:
@html.actionlink( "remove item", "removeitemedit", new { @_cardid = model.mpacktoedit.mlistcardpack[i].mcard.mmastercard.mcardid }, new { "onclick" = "needtoconfirm = false" })
Comments
Post a Comment