在mvc中创建确认框,在视图中使用jquery

时间:2017-05-31 11:09:28

标签: jquery asp.net-mvc

在asp中如果我去方法中显示确认框我只使用这个

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "confirm('Record Inserted Successfully')", true);

但是如果我去做同样的话,我会找不到任何办法

1 个答案:

答案 0 :(得分:1)

如果您需要简单的确认,您始终可以使用简单的js confirm方法。

例如,如果您要确认form submit - 您可以这样做:

<form onsubmit="return confirm('Will we post?');">

如果你有与href的链接,你可以用Razor语法这样做:

@Html.ActionLink("YourAction", "YourController",
    null, //here you can pass additional parameters to href
    new { onclick = "return confirm('Are you sure you want this?');" })