简体   繁体   English

.NET MVC4创建或选择外键

[英].NET MVC4 Create or select foreign key

I cant figure how to work this out, maybe you can help me. 我不知道如何解决这个问题,也许您可​​以帮助我。 I have a MVC4 project with a customer model and an event model . 我有一个带有customer modelevent modelMVC4项目。

When I access the create view for the event, I would like to select a customer (via dropdownlist , this is ok and working) or if the customer I want is not created yet, create it inside the event create view (not to close this view, open customer view, create customer, go back to event create view...). 当我访问事件的create view ,我想选择一个客户(通过dropdownlist ,这可以正常工作),或者如果尚未创建我想要的客户,请在事件create view创建它(不要关闭此create view视图,打开客户视图,创建客户,返回活动创建视图...)。 How can I do that? 我怎样才能做到这一点? Any ideas? 有任何想法吗?

Thanks everybody! 谢谢大家!

Can be done through the form and ess or partial view. 可以通过表单和基本视图或局部视图来完成。 I understand the question? 我明白这个问题吗?

HTML HTML

<div id="dialog-form">
        <form>
            ...
        </form>
    </div>

js JS

function openDialogForm() {
    $("#dialog-form").dialog("open");
}


function closeDialogForm() {
    $("#dialog-form").dialog('close');
}

function dialogForm() {
    if ($('#dialog-form').length) {
        $('#dialog-form').dialog({
            autoOpen: false,
            height: 200,
            width: 475,
            modal: true,
            resizable: false,
            show: "slow",
            open: function () { $('.ui-widget-overlay').bind('click', function () { $("#dialog-form").dialog('close'); }); }
        });
    }

Your implementation may be another. 您的实现可能是另一种实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM