0

首先,我想说的是,在使用 javascript 时,我完全是个菜鸟,而且这是我第一次在项目中使用弹出窗口。

直到现在我才这样做(索引视图):

<button type="button" class="btn btn-info btn-xs" data-toggle="modal" data-target="#enquirypopup">Add Event</button>//Table with the list of entries.
<div id="enquirypopup" class="modal fade in" role="dialog" tabindex="-1">
    <div class="modal-dialog">

        <!-- Modal content-->
        <div class="modal-content row">
            <div class="modal-header custom-modal-header">
                <button type="button" class="close" data-dismiss="modal">×</button>
                <h4 class="modal-title">Add Event</h4>
            </div>
            <div class="modal-body">
            //This is only a bit off what I have tried
                @*<form name="info_form" class="form-inline" action="#" method="post">*@
                @*<form name="info_form" class="form-inline" action="Project/Areas/User/Events/Add" method="post">*@
                @*<form name="info_form" class="form-inline" action="@Url.Action("Index", "Events")" method="post">*@
                @*<form name="info_form" class="form-inline" action="@Url.Action("Add")" method="post">*@
                
                <form name="info_form" class="form-inline" action="/Events/Add" method="post">
                    <div class="form-group col-sm-12">
                        <label>Event Title: </label>
                        <br />
                        <input type="text" class="form-control" name="Event" id="Event" placeholder="Event Name">
                    </div>
                    <br />
                    <br />
                    <div class="form-group col-sm-12">
                        <label>Starting Date and Time: </label>
                        <br />
                        <input type="text" class="form-control" name="Start_Date" id="Start_Date" placeholder="ll/zz/aaaa hh:mm:ss">
                    </div>
                    <br />
                    <br />
                    <div class="form-group col-sm-12">
                        <label>Ending Date and Time: </label>
                        <br />
                        <input type="text" class="form-control" name="End_Date" id="End_Date" placeholder="ll/zz/aaaa hh:mm:ss">
                    </div>
                    <br />
                    <br />
                    <div class="modal-footer">
                        @*<div class="form-group col-sm-12">*@
                        <button type="submit" class="btn btn-success pull-right">Save</button>
                        @*</div>*@
                    </div>
                </form>
            </div>

        </div>

    </div>
</div>

这是控制器:

public ActionResult Index()
    {
        return View(db.tbl_Event.ToList());
    }

[HttpGet]
    //public PartialViewResult Add()
    public ActionResult Add()
    {
        //return PartialView("_Event");
        return View();
    }

    [HttpPost]
    //public PartialViewResult Add(BOL3.tbl_Event eve)
    public ActionResult Add(BOL3.tbl_Event eve)
    {
        db.tbl_Event.Add(eve);
        db.SaveChanges();

        //return Add();
        //return View("Index");
        //return View();
        return RedirectToAction("Index", eve);
    }

当我将输入的数据保存到弹出窗口时,它显示错误:“找不到视图'索引'或其主控或没有视图引擎支持搜索的位置。搜索了以下位置:bla/bla/bla”,但它不显示索引视图的正确路径。这就是我的问题,当我保存数据时,我想关闭弹出窗口和要在列表中显示的值(索引视图)。请帮助我,因为我搜索了许多网站来帮助我做到这一点,但对我没有任何帮助。

4

0 回答 0