使用Ajax我怎样才能使一个确认的问题吗? [英] How can i make a confirm question using Ajax?

查看:127
本文介绍了使用Ajax我怎样才能使一个确认的问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的按钮:

@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?

推荐答案

标准链接:

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

如果你要使用AJAX链接:

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?" }
)

或AJAX形式:

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

这篇关于使用Ajax我怎样才能使一个确认的问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆