将模态数据(弹出式窗体)保存到本地数据库-ASP.NET MVC

时间:2019-04-18 07:33:35

标签: asp.net-mvc

我设法成功实现插入功能,如下所示。但这是通过使用另一个视图-“创建”完成的。一旦提交,它将进入“ ViewSecurityForm”视图。但是现在,我想在“ ViewSecurityForm”中使用模式来实现插入功能。我在“ ViewSecurityForm”视图中要实现的模态很少。你能帮我怎么做吗?

我在“创建”视图中创建函数的方法:

   public ActionResult Create(ServerInfo alldata)
    {
        try
        {

            db.ServerInfos.Add(alldata);
            db.SaveChanges();


            return RedirectToRoute(new { controller = "Employee", action = "ViewSecurityForm" });
        }
        catch

        {
            return View();
        }
    }

我在“ ViewSecurityForm”视图中的模态方法:

public ActionResult ViewSecurityForm()
{


/*What should I write here*/      


}

我的课程:

public class ViewSecurityForm
{
    public List<ServerInfo> allServerInfo { get; set; }
    public List<NetworkDeviceInfo> allNetworkDeviceInfo { get; set; }

}


public class SecurityContext : DbContext
{
    //Create database without name 
    public SecurityContext ()
    {       

        Database.SetInitializer(new SecurityDBInitializer());
    }

    //Create Table as below            
    public DbSet<ServerInfo> ServerInfos { get; set; }
    public DbSet<NetworkDeviceInfo> NetworkDeviceInfos { get; set; }


}

My Modal image

0 个答案:

没有答案