ASP.NET C#从代码后面打开对话框

时间:2014-09-02 01:28:28

标签: c# asp.net

我需要从ASP.NET C#中的服务器端脚本打开一个Jquery对话框。

以下是Jquery中对话框的样子:

    $("#dialog-confirm").dialog({            
        resizable: false,
        modal: true,
        title: "Modal",
        height: 250,
        width: 400,

        buttons: {
            "Register": function () {

            },
            "Cancel": function () {
                $(this).dialog('close');                    
            }
        }
    });

我需要代码从后面的代码中调用此对话框,我正在尝试使用类似的东西;

  ScriptManager.RegisterStartupScript(this.GetType(), "Pop", " $('#dialog-confirm').dialog('open');", true);

需要帮助,使用最合适的方式从后面的代码打开一个对话框,因为我的工作不起作用。没有任何事情发生

1 个答案:

答案 0 :(得分:0)

在调用open之前,您需要先初始化对话框。例如:

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Pop", "$(function(){$('#dialog-confirm').dialog();$('#dialog-confirm').dialog('open');});", true);  

JS的工作原理如下:

$(function(){ //Page is ready
    $('#dialog-confirm').dialog(); //init dialog
    $('#dialog-confirm').dialog('open'); //open dialog
});
相关问题