This is a migrated thread and some comments may be shown as answers.

Opening radwindow from registerstartupscript, can't pass parameter

2 Answers 318 Views
Window
This is a migrated thread and some comments may be shown as answers.
Garrett
Top achievements
Rank 1
Garrett asked on 10 Jun 2014, 09:33 PM
Here is my javascript:

<script type="text/javascript">
    function ShowWindow(dealid) {
        
        var oWnd = window.radopen('Windows/DealReassignmentPopup.aspx', 'window1');
    }
</script>

and my code behind:

protected void gridAssignSingleDeal_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
            if (e.CommandName == "OpenWindow")
        {
            int datakeyvalue = Helper.IntHelper((e.Item as GridDataItem).GetDataKeyValue("ID"));
   
           string script = string.Format("<script language='javascript' type='text/javascript'>Sys.Application.add_load(ShowWindow({0}));</script>",datakeyvalue);
            ClientScript.RegisterStartupScript(this.GetType(), "showWindow", script);
                        
        }
    }


If I do not pass it any parameters ( take out string.format) it works. If I try to pass it a parameter, it does not, it says this error:

Unhandled exception at line 17467, column 1 
0x800a138f - JavaScript runtime error: Unable to get property 'open' of undefined or null reference





All I want to do is have a button on my grid that when I click it, it opens a radwindow with a parameter. If I have to do this another way, I am up for that.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Jun 2014, 03:35 AM
Hi Garrett,

Please modify the C# code snippet as follows which works fine at my end.

C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (e.CommandName == "OpenWindow")
    {
        int datakeyvalue = Convert.ToInt32((e.Item as GridDataItem).GetDataKeyValue("OrderID"));
        string script = "function f(){ShowWindow('" + datakeyvalue + "'); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
    }
}

Thanks,
Shinu.
0
Garrett
Top achievements
Rank 1
answered on 11 Jun 2014, 03:56 AM
You are the best Shinu, you always fix my issues, thanks!
Tags
Window
Asked by
Garrett
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Garrett
Top achievements
Rank 1
Share this question
or