In my page I have the following script:
<script language="javascript">
var needToConfirm = true;
window.onbeforeunload = confirmExit;
function confirmExit() {
if (needToConfirm) {
return "You have attempted to leave this page. " +
"If you have made any changes to the fields without clicking the Save button, your changes will be lost." +
" Do you wish to proceed?";
}
}
</script>
I am able to set the needToConfirm value in a button like this:
<input type="submit" value="Save" name="_submitButton" onclick="needToConfirm = false"/>
I want to know if there's a similar way to do this in an actionLink like this one:
@Html.ActionLink("Remove this item", "RemoveItemEdit", new
{
@_cardID = Model.mPackToEdit.mListCardPack[i].mCard.mMasterCard.mCardID,
needToConfirm = false
})
I've tried this but it doesn't work.