简体   繁体   English

如何在MVC C#中显示具有多个模型属性的外键

[英]How to display Foreign Key with multiple model properties in MVC C#

let's say I have 假设我有

Customer Model: 客户模型:

ID
UserName
Password
LastName
FirstName
City
Street
BuildingNumber
...

ServiceCall Model: 服务电话型号:

ID
CustomerID
....

In my application every person in the building can open a service call using the building UserName and Password. 在我的应用程序中,建筑物中的每个人都可以使用建筑物的UserName和Password打开服务呼叫。 In addition to this option they can also call to the company's office and ask the secretary to open a service call for them. 除此选项外,他们还可以致电公司办公室,并要求秘书为他们开通服务电话。 I want to allow the secretary to search the client by a full address, since the customer may not remember his ID,UserName...and so. 我想允许秘书通过完整的地址搜索客户,因为客户可能不记得他的ID,用户名...等等。 I thought to add search button which will open a bootstrap modal with customer search... 我想添加搜索按钮,这将打开带有客户搜索的引导模式...

what is the best way to implement a pop up that will include search option to another model? 实现弹出式窗口(将搜索选项包含到另一个模型中)的最佳方法是什么?

This is for the modal 这是模态

<div id="form-content" class="modal hide fade in" style="display: none;">
    <div class="modal-header">
        <a class="close" data-dismiss="modal">×</a>
        <h3>Send me a message</h3>
    </div>
    <div class="modal-body">
        <form class="contact" name="contact">
            <label class="label" for="name">Name</label><br>
            <input type="text" name="name" class="input-xlarge"><br>
            <label class="label" for="email">E-mail</label><br>
            <input type="email" name="email" class="input-xlarge"><br>
        </form>
    </div>
    <div class="modal-footer">
        <input class="btn btn-success" type="submit" value="Search" id="submit">
        <a href="#" class="btn" data-dismiss="modal">Cancel</a>
    </div>
</div>
<div id="thanks"><p><a data-toggle="modal" href="#form-content" class="btn btn-primary btn-large">Click me to open search</a></p></div>

$(document).ready(function () {
    $("input#submit").click(function(){
        $.ajax({
            type: "POST",
            url: "process.php", //process to mail
            data: $('form.contact').serialize(),
            success: function(msg){
                $("#thanks").html(msg) //hide button and show thank you
                $("#form-content").modal('hide'); //hide popup  
            },
            error: function(){
                alert("failure");
            }
        });
    });
});

Then you just have to make the ajax call to server and return to close modla and show results or replace the modal's content by the returned persons. 然后,您只需要对服务器进行ajax调用,然后返回以关闭modla并显示结果,或者由返回的人员替换模式内容。

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

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