0

如何使用 MVC 引导程序创建弹出窗口?

我有这个代码,当我点击“生成密码”调用一个函数(它在我的控制器管理员中)并返回一个字符串。如何在弹出窗口中显示字符串?

<div class="editor-field" title="User Password">
    <a class="btn btn-primary btn-small" href="#" 
    onclick="location.href='@Url.Action("GeneratePsw", "Admin", null)'; return false;">
        <i class="icon-lock icon-white"></i> Generate password
    </a> 
</div>
4

2 回答 2

1

由于事件监听器比点击事件更好,我可能会做这样的事情:

<div class="editor-field" title="User Password">
    <a id="pwd_gen" class="btn btn-primary btn-small" href="#">
        <i class="icon-lock icon-white"></i> Generate password
    </a> 
</div>

$(function() { // document.ready shorthand
    $('#pwd_gen').click(function() {
        var myPwd = $(this).location.href='@Url.Action("GeneratePsw", "Admin", null);
        alert(myPwd); // or however you want to handle it with Bootstrap
    });
});
于 2013-03-13T15:06:10.293 回答
0
$(document).on("click", ".open-ShowPwdDialogUser", function () { 

    var pwd="";


    $.get("@Url.Action("GeneratePsw", "Admin")",function(data){

        pwd=data;

        $(".modal-body #pwdUser").val(pwd);
        $('#1').modal('show');


    }); 


})
于 2013-03-21T15:23:21.177 回答