弹出与引导程序

时间:2013-03-13 14:52:51

标签: html asp.net-mvc twitter-bootstrap

如何使用MVC bootstrap创建弹出窗口?

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

<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>

2 个答案:

答案 0 :(得分: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
    });
});

答案 1 :(得分: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');


    }); 


})