我有以下链接。单击时,我想检查 item.primary_company 字段,如果已填充,则向用户发出警告并询问他们是否要继续。我怎样才能做到这一点?
<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>
编辑
我已更改为此,但单击时没有任何反应。另外,我不知道如何引用该项目来检查 primary_company 字段。我只想发消息显示 item.primary_company.HasValue。我还想在确认消息中显示 item.company1.company_name。
<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>