Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run telerik RadWindow from code behind

I am trying to run telerik rad window from code behind. But I have some issues. I don't know is it important but I am trying to run rad window from button clicked in edit mode from rad grid.

RadWindow window1 = new RadWindow();
window1.NavigateUrl = "http://www.google.com";
window1.VisibleOnPageLoad = true;
window1.ID = "RadWindow1";
window1.Width = 500;
window1.Height = 300;
window1.VisibleOnPageLoad = true;    
rwm_WindowManager.Windows.Add(window1);

On the page I also have RadAjaxManager and rwm_WindowManager I put in RadAjaxPanel.
Problem is that this rad window never shows up. There are no errors but no rad window also.

like image 741
1110 Avatar asked Dec 28 '11 09:12

1110


2 Answers

 <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        </telerik:RadWindowManager>
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
            OnItemCommand="RadGrid1_ItemCommand">
            <MasterTableView DataKeyNames="ID">
                <Columns>
                    <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn>
                        <ItemTemplate>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Button ID="Button1" Text="Open window" CommandName="OpenWindow" runat="server" />
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridEditCommandColumn>
                    </telerik:GridEditCommandColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>

........................

 protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    dynamic data = new[] {
            new { ID = "1", Name ="Name11",ParentID = "0"},
            new { ID = "2", Name ="Name11",ParentID = "0"},
            new { ID = "3", Name ="Name11",ParentID = "0"},
            new { ID = "4", Name ="Name11",ParentID = "0"}
        };
    RadGrid1.DataSource = data;
}
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "OpenWindow")
    {
        //RadWindowManager
        RadWindow window1 = new RadWindow();
        window1.NavigateUrl = "http://www.google.com";
        window1.VisibleOnPageLoad = true;
        window1.ID = "RadWindow1";
        window1.Width = 500;
        window1.Height = 300;
        RadWindowManager1.Windows.Add(window1);

    }
}

put your RadWindowManager inside RadAjaxPanel.

like image 184
Jayesh Goyani Avatar answered Nov 01 '22 22:11

Jayesh Goyani


I just had a similar issue. I resolved it like so:

RadAjaxManager.GetCurrent(Page).ResponseScripts.Add(String.Format("$find('{0}').show();", window1.ClientID));

My applications use RadAjax which makes the VisibleOnPageLoad property problematic, so I avoid it altogether.

like image 37
ricksmt Avatar answered Nov 01 '22 22:11

ricksmt