How can i make a confirm question using Ajax?

大憨熊 提交于 2020-01-15 08:51:06

问题


this is my button:

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

I tried to make a confirm 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?


回答1:


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" />
}


来源:https://stackoverflow.com/questions/7261685/how-can-i-make-a-confirm-question-using-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!