I am trying to add a confirmation dialog to an action link. I have a parameter in the URL called "interviewTypeID" that needs to be passed to the controller.
I referenced this link here for my code:
This is my code:
@Html.ActionLink("Instructions", "Index", "KnowledgeTransferController", new { interviewTypeID = Request.QueryString["interviewTypeID"], employeeNumber = Request.QueryString["employeeNumber"], ID = Request.QueryString["ID"] }, new {onclick="return confirm('Are you sure?');"})
However whenever I add the onclick in the HtmlAttribute parameter, the link breaks because it does not pass the interviewTypeID parameter set by set by Request.QueryString. At first I thought the Request.QueryString is broken by the javascript. But even when I write
, new {}
it still breaks, without any javascript added.
How do I create an alert for this ActionLink while still passing parameters from the URL?
Thank you for your help.
Edit:
It isn't that it isn't passing variables. It redirects to the following invalid URL:
I need to parse it into the correct format. It does this automatically when there is no html attribute.
I also tried this:
<a href="@Url.Action("Overview", "KnowledgeTransferController", routeDic, "http", string.Empty)" onclick="SaveConfirmation()">Overview</a>