How to give user confirmation message before ActionLink based on validation
- by RememberME
I have the following link. On click, I'd like to check the item.primary_company field and if populated, give the user a warning and ask if they would like to continue. How can I do this?
<a href="<%= Url.Action("Activate", new {id = item.company_id}) %>" class="fg=button fg-button-icon-solo ui-state-default ui-corner-all"><span class="ui-icon ui-icon-refresh"></span></a>
EDIT
I've changed to this, but nothing happens when clicked. Also, I don't know how to reference the item to do the check on the primary_company field. I only want to message to show if item.primary_company.HasValue. I'd also like to show item.company1.company_name in the confirm message.
<a href="#" onclick="return Actionclick("<%= Url.Action("Activate", new {id = item.company_id}) %>");" class="fg=button fg-button-icon-solo ui-state-default ui-corner-all"><span class="ui-icon ui-icon-refresh"></span></a>
<script type="text/javascript">
function Actionclick(url)
{
alert("myclick");
if ( confirm("Do you want to activate this company's primary company and all other subsidiaries?"))
{
location.href(url);
}
};
</script>