How to give user confirmation message before ActionLink based on validation

Posted by RememberME on Stack Overflow See other posts from Stack Overflow or by RememberME
Published on 2010-05-16T03:19:17Z Indexed on 2010/05/16 19:50 UTC
Read the original article Hit count: 191

Filed under:
|
|
|
|

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>

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about url.action