创建一个jQuery弹出的ASP.NET MVC的LINQ2SQL和/编辑/保存数据 [英] Create/Edit/Save data in a jQuery pop-up for ASP.NET-MVC and Linq2Sql

查看:158
本文介绍了创建一个jQuery弹出的ASP.NET MVC的LINQ2SQL和/编辑/保存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC页面,允许转包的创建和编辑。当用户有选择的分包公司,我想为他们必须创建一个新的公司的选项。我做了一个jQuery弹出与该公司领域,但我不知道如何保存此信息到公司表。我还希望能够使用相同的弹出,以允许用户编辑一个现有的公司的信息,但需要在如何将信息发送到弹出方向

I have a MVC page which allows creation and editing of a subcontract. When the user has to select a company for the subcontract, I would like for them to have the option to create a new company. I've made a jQuery pop-up with the company fields, but I don't know how to then save this information to the company table. I would also like to be able to use the same pop-up to allow the user to edit the information for an existing company, but need direction in how to send the information to the pop-up.

推荐答案

使用AJAX来无论从弹出的形式发送数据(jQuery的对话,真的)返回到服务器并填充当你想对话做编辑。

Use AJAX to both send the data from a form in the pop-up (jQuery dialog, really) back to the server and to populate the dialog when you want to do the editing.

$('#addSubcontract').click( function() {
    $.get('/company/new', null, function(data) {
        $('<div>' + data + '</div>').dialog({
            modal: true,
            buttons: {
               'Add': function() {
                        var dialog = $(this);
                        var form = $(this).find('form');
                        $.post('/company/new', $(form).serialize(), function() {
                            dialog.dialog('destroy');
                        }
                      }
               'Cancel': function() {
                      $(this).dialog('destroy');
                      }
           },
           ...
       }
    });
});

这篇关于创建一个jQuery弹出的ASP.NET MVC的LINQ2SQL和/编辑/保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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