RadWindow没有打开

时间:2013-11-07 14:06:55

标签: c# javascript telerik radwindow

单击按钮

时,RadWindow无法打开

我的javascript代码:

<script type="text/javascript">
    function OpenURL(URL) {
        var oWnd1 = radopen(URL, "Detalhamento do Contrato");
        oWnd1.set_height("600px");
        oWnd1.set_width("600px");
        oWnd1.center();
        oWnd1.set_modal(true);

    }
</script>

我的C#代码:

    protected void RadGrid_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName.Equals("Detalhes"))
        {
            String Parametros = "ContratoNumero=" + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["CONT_NUMERO"];
            Parametros += "&AditivoNumero=" + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["CONT_NUMADITIVO"];
            Parametros += "&ContratoTipo=" + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["CONT_TIPO"];
            Parametros += "&Exercicio=" + this.txtExercicio.Text;

            string URL = "ContratoDetalhamento.aspx?" + Parametros;

            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "relatorio", String.Format("OpenURL('{0}','{1}');", URL, DateTime.Now.Ticks), true);
        }
    }

有人能帮助我吗? 现在谢谢

3 个答案:

答案 0 :(得分:0)

你错过了:

oWnd1.SetActive();

答案 1 :(得分:0)

1)在此处查看正确执行脚本:http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html

2)在这里看一下正确的radopen()语法:http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html

我将如何做到这一点:

function OpenURL(URL) {
    var oWnd1 = radopen(URL, "RadWindowName");//note, no spaces
    oWnd1.setSize(600, 600);//width, height
    oWnd1.set_modal(true);//making it modal will center it by default

}

现在,请确保您执行的代码足够晚:

string script = "function(f){openURL('url'); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "someKey", script, true);

答案 2 :(得分:0)

您好我想与您分享我的解决方案,仅在Javascript代码中创建RadWindow对话框。

我们需要实现2个方法:一个用于初始化RadWindow对话框,最后一个用于接收关闭RadWindow后返回的参数。您可以在第二步(e.x postback,...)

中执行您想要的操作

这是我的代码:

初始化RadWindow对话框:

function openMyDialog(url, args) {
    var manageWindow = GetRadWindowManager();
    if (manageWindow) {
        var radWindow = manageWindow.open(url, "<your_dialog_name>");
        if (radWindow) {
            radWindow.set_initialBehaviors(Telerik.Web.UI.WindowBehaviors.None);
            radWindow.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Resize);
            radWindow.setActive(true);
            radWindow.SetModal(true);
            radWindow.center();
            radWindow.set_visibleStatusbar(false);
            radWindow.set_keepInScreenBounds(true);
            radWindow.set_minWidth(640);
            radWindow.set_minHeight(480);
            radWindow.setSize(640, 480);
            radWindow.set_destroyOnClose(true);
            radWindow.add_close(closeMyDialog);//after closing the RadWindow, closeMyDialog will be called
            radWindow.argument = args;//you can pass the value from parent page to RadWindow dialog as this line
        }
    }
}

关闭RadWindow对话框:

function closeMoveProjectDialog(sender, args) {
    var objArgs = args.get_argument();
    //objArgs variable stored the values returned from the RadWindow
    //you can use it for your purpose
}

如何称呼它?您可以将open方法放入预期的方法中。在我这边,我有一个如下所示的方法,我将以这种方式调用RadWindow:

function ShowForeignKeyFrontEditSingle(param1, param2){
    var url = "ForeignKeyFrontEditSingle.aspx";
    var objArgs = new Array();
    objArgs[0] = param1;
    objArgs[1] = param2;

    openMyDialog(url, objArgs);
    return;
}

当然,您必须声明RadWindowManager控件

function GetRadWindowManager() {
    return $find("<%=your_radwindow_manager_control.ClientID%>");
}