开发者

How can i make a confirm question using Ajax?

开发者 https://www.devze.com 2023-04-01 11:58 出处:网络
this is my button: @Html.ActionLink(\"Deletar\", \"Deletar\", new { id = item.ID }) I tried to make a confir开发者_JAVA技巧m question with Ajax like this

this is my button:

@Html.ActionLink("Deletar", "Deletar", new { id = item.ID })

I tried to make a confir开发者_JAVA技巧m question with Ajax like this

@using (Ajax.BeginForm(
            "AjaxAction",
            new AjaxOptions {OnBegin ="Deletar",Confirm="Você realmente deseja isso?" }))
           { @Html.ActionLink("Deletar", "Deletar",  new { id = item.ID },new { id = "Deletar" }) }

it does not work? what can i do?


With standard link:

@Html.ActionLink(
    "Deletar", 
    "Deletar", 
    new { id = item.ID }, 
    new { onclick = "return confirm('Você realmente deseja isso?');" }
)

or if you want to use an AJAX link:

@Ajax.ActionLink(
    "Deletar", 
    "Deletar", 
    new { id = "item.ID" },
    new AjaxOptions { OnBegin = "Deletar", Confirm = "Você realmente deseja isso?" }
)

or an AJAX form:

@using (Ajax.BeginForm("AjaxAction", new { id = item.ID }, new AjaxOptions { OnBegin = "Deletar", Confirm = "Você realmente deseja isso?" }))
{ 
    <input type="submit" value="Deletar" />
}
0

精彩评论

暂无评论...
验证码 换一张
取 消