Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.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
Javascript MVC4中的警报框?_Javascript_Asp.net Mvc - Fatal编程技术网

Javascript MVC4中的警报框?

Javascript MVC4中的警报框?,javascript,asp.net-mvc,Javascript,Asp.net Mvc,这就是我要为ActionLink制作的警报框。但它不起作用 @Html.ActionLink("ADD", "BrandListComfirmed", new { id = item.brand_id }, new { onsubmit = "return confirm('Are u sure you want this brand? " + item.brand_name + "');" }) 没有锚的onsubmit事件。改用onclick: @Html.ActionLink(

这就是我要为ActionLink制作的警报框。但它不起作用

@Html.ActionLink("ADD", "BrandListComfirmed", new { id = item.brand_id }, new { onsubmit = "return confirm('Are u sure you want this brand? " + item.brand_name + "');" })

没有锚的
onsubmit
事件。改用
onclick

@Html.ActionLink(
    "ADD", 
    "BrandListComfirmed", 
    new { 
        id = item.brand_id 
    }, 
    new { 
        onclick = "return confirm('Are u sure you want this brand? " + item.brand_name + "');" 
    }
)

非常感谢。我可以在db.savechange之前使用控制器中的警报框吗?不可以,
alert
是一个javascript函数,它只能在客户端上使用。控制器在服务器上运行。