Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 单击按钮时新的onclick返回_Html_Model View Controller_Onclick_Return - Fatal编程技术网

Html 单击按钮时新的onclick返回

Html 单击按钮时新的onclick返回,html,model-view-controller,onclick,return,Html,Model View Controller,Onclick,Return,下面是现有代码,但我想添加一个新的onclick,它返回一个弹出框,询问用户是否确定要删除配置文件。但是我想不出来 现行守则: @if(mode == "Edit"){ <div class="Delete"><a class="btn btn-danger" href ="@Url.Action("Delete", "GPS", new { Id = Model.provider.Company.Id.Value, oem = Model.provider.

下面是现有代码,但我想添加一个新的onclick,它返回一个弹出框,询问用户是否确定要删除配置文件。但是我想不出来

现行守则:

 @if(mode == "Edit"){
        <div class="Delete"><a class="btn btn-danger" href ="@Url.Action("Delete", "GPS", new { Id = Model.provider.Company.Id.Value, oem = Model.provider.Id})">Delete Profile</a></div>  
        }

在js中,应该是这样的:

if (confirm('Are you sure you want to delete the profile?')){
   // code to execute if ok is pressed
   // in your case it could be a redirection to the url you need
} else {
   // code if canceled is pressed, may not be used
}
需要知道的是,它是有效的,因为如果确定,确认将返回true,如果取消,则返回false

if (confirm('Are you sure you want to delete the profile?')){
   // code to execute if ok is pressed
   // in your case it could be a redirection to the url you need
} else {
   // code if canceled is pressed, may not be used
}