ASP.net MVC成功警报窗体后提交 [英] ASP.net MVC Success Alert After Form submit

查看:244
本文介绍了ASP.net MVC成功警报窗体后提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示表格submited和行动succeded
后成功弹出式警报或警告信息
在这个例子中,我想显示成功添加:
 创建动作

I want to display success Alert pop-up or alert message after form submited and action succeded
In this example I want to show "successfully add" : Create Action :

[HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Create(TAUX taux)
    {
        if (ModelState.IsValid)
        {
            db.TAUX.Add(taux);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        ViewBag.CAT_ID = new SelectList(db.CATEGORIE, "CAT_ID", "LIBELLE", taux.CAT_ID);
        ViewBag.C_GARANT = new SelectList(db.GARANTIE, "C_GARANT", "LIB_ABREGE", taux.C_GARANT);
        return PartialView("_Create", taux);
    }

索引操作

public ActionResult Index()
        {
            var taux = db.TAUX.Include(t => t.CATEGORIE).Include(t => t.GARANTIE);
            return View(taux.ToList());
        }

我应该加入到这样做呢?

What should I add to do this ?

推荐答案

我用来做的Ajax表单,并在的onSuccess 温控功能我显示消息:

I used to make Ajax Form and in the OnSuccess fucntion i show message :

@using (Ajax.BeginForm("Edit1", "Availability", new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.InsertBefore, UpdateTargetId = "formAddAvailabilityContainer", OnSuccess = "AddAvailabilitySuccess" }, new { @class = "AjaxForm", @id = "formAvailability_" + Model.Id }))
    {
        @Html.ValidationSummary(true)




        @Html.HiddenFor(model => model.Id)
        @Html.HiddenFor(model => model.UserId)

        @Html.EditorFor(model => model.StartTime)
        @Html.MyValidationMessageFor(model => model.StartTime)

        @Html.EditorFor(model => model.EndTime)
        @Html.MyValidationMessageFor(model => model.EndTime)

        @Html.EditorFor(model => model.RecurrenceFreq)
        @Html.MyValidationMessageFor(model => model.RecurrenceFreq)



      @Html.TextBoxFor(model => model.EndsAfterValue, new {id="txtBoxEndsAfterValue" })
     @Html.MyValidationMessageFor(model => model.EndsAfterValue)



    @Html.EditorFor(model => model.EndsByDate)


    <input type="submit" class="btn btn-primary" value="Save" id="btnsubmit" />
   <input type="button" class="btn btn-primary btnCancelAvailability" id="0" value="Cancel">


    }


 <script>

    function AddAvailabilitySuccess()
    {

    alert("Record updated successfully!");

    }

    </script>

这篇关于ASP.net MVC成功警报窗体后提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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