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

can i use Window as Controls Container?

13 Answers 151 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jana
Top achievements
Rank 1
Jana asked on 15 May 2010, 10:21 AM
i just wanna to make method that creates new window and passes a paramter of Control.ascx path

then the window loades it in ContentTemplate?????

13 Answers, 1 is accepted

Sort by
0
Petio Petkov
Telerik team
answered on 15 May 2010, 02:17 PM
Hello,

You can use the RadWindow control as controls container. Please refer to the following online demo for an overview of this functionality:
http://demos.telerik.com/aspnet-ajax/window/examples/internalcontent/defaultcs.aspx

I would recommend that you use an initially hidden RadWindow control ( VisibleOnPageLoad ="false") and show it with JavaScript, e.g.
<script type="text/javascript">
        function ShowWindow()
        {
            var oWnd = $find("<%=RadWindow1.ClientID%>");
            oWnd.show();
        }
    </script>

In case I misunderstood your requirement, please provide detailed information on the behavior you are trying to implement with our control.

Greetings,
Petio Petkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jana
Top achievements
Rank 1
answered on 15 May 2010, 04:01 PM
no, i did not mean that


i meant i am creating util class public for all project has Method "ShowNewWindow(string ControlPath)"

i call this method more than one may be when user press link or button whatever


anyway method already create new radwindow and then load ControlPath.ascx init


it loads and everything goes right but when i call 2 windows to show one window only can be shown


and if Control.ascx conatins javascript code

it did not load it

i am using Page.LoadControl method
0
Petio Petkov
Telerik team
answered on 17 May 2010, 04:14 PM
Hi Janna,

In case that you create RadWindow (with Controls Container) dynamically, you should recreate its content on each PostBack. I created for you a simple example, which illustrates how to create RadWindow dynamically and recreate the UserControls in it, on each PostBack.
ASPX:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"/>
      
    <div>
      <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
      <asp:Button ID="Button1" runat="server" Text="Add Window With WebUserControl1" OnClick="Button1_Click"/>
      <asp:Button ID="Button2" runat="server" Text="Add Window With WebUserControl2" OnClick="Button2_Click"/>
      <asp:Button ID="btnPostback" runat="server" Text="Postback" />
    </div>
    </form>
</body>
</html>
CodeBehind:
protected void Page_Load(object sender, EventArgs e)
{
    foreach (RadWindow window in RadWindowManager1.Windows)
    {
        string UserControlPath = window.Title;
        window.ContentContainer.Controls.Add(Page.LoadControl(UserControlPath));
    }
}
protected void Button1_Click(object sender, EventArgs e)
{
    CreateRadWindow("WebUserControl1.ascx");
}
protected void Button2_Click(object sender, EventArgs e)
{  
    CreateRadWindow("WebUserControl2.ascx");
}
protected void CreateRadWindow(string Path)
{
    RadWindow window = new RadWindow();
    window.Title = Path;
    window.VisibleOnPageLoad = true;
    window.ContentContainer.Controls.Add(Page.LoadControl(Path));
    RadWindowManager1.Windows.Add(window);
}
In case that this is not you looking for, please open a new support thread, and send us a running project where we can observe the problem you experience, and we will do our best to help you.

All the best,
Petio Petkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jana
Top achievements
Rank 1
answered on 17 May 2010, 06:23 PM
yea works great :) thx

but when i have Control.ascx and contains button
when i click the button it displays emtpy window and does not fire button click !!!!
0
Svetlina Anati
Telerik team
answered on 18 May 2010, 03:01 PM
Hi janna janna,

I am afraid that the provided explanation is not enough to understand what is the problem. As far as I understood you have a button on the page and you want to create dynamically and show a RadWindow when the button is clicked. If so, I do not see how you open an empty  RadWindow when the button is clicked since you say that the server event is not fired and the RadWindow is created and added to the form there. I believe that the best way to proceed is to modify the code my colleague Petio last sent you and share fully runnable source code here along with very detailed explanations which is the button in question, what is the actual and the expected behavior and the differences between them and once we have a better understanding on your exact setup and requirements we will do our best top help.

Regards,
Svetlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jana
Top achievements
Rank 1
answered on 28 May 2010, 09:15 PM
sorry for late :$


i mean like this code

RadWindow W = new RadWindow();
Control C = base.LoadControl("url.ascx");
W.ContentContainer.Controls.Add(C);
WindowManager.Windows.Add(W);


this is runtime code when i fire some event and call this code , it makes error !!!
0
Jana
Top achievements
Rank 1
answered on 01 Jun 2010, 10:01 AM
does anyone test my code?
0
Petio Petkov
Telerik team
answered on 01 Jun 2010, 05:04 PM
Hi,

I tested the code below, which is similar to yours and it works as expected.
ASPX:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <telerik:RadWindowManager ID="WindowManager" runat="server">
        </telerik:RadWindowManager>
        <asp:Button ID="Button1" runat="server" Text="AddWindow" OnClick="Button1_Click"/>
    </div>
    </form>
</body>
</html>
Codebehind:
protected void Button1_Click(object sender, EventArgs e)
   {
       RadWindow W = new RadWindow();
       Control C = base.LoadControl("url.ascx");
       W.ContentContainer.Controls.Add(C);
       WindowManager.Windows.Add(W);
   }
Please send us the entire page's code, which will help us to reproduce the problem on our side. Once we receive it, we will do our best to help you.

Sincerely yours,
Petio Petkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jana
Top achievements
Rank 1
answered on 02 Jun 2010, 11:11 AM

//Code behind  
 
protected void Button1_Click(object sender, EventArgs e)  
        {  
            RadWindow W = new RadWindow();  
            W.ContentContainer.Controls.Add(this.LoadControl("x.ascx"));  
            W.VisibleOnPageLoad = true;  
            this.RadWindowManager1.Windows.Add(W);  
        } 





Control x.ascx

// x.ascx  
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="x.ascx.cs" Inherits="WebApplication1.x" %>  
<p>  
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />  
</p>  
 
 

// code behind  
 
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
 
namespace WebApplication1  
{  
    public partial class x : System.Web.UI.UserControl  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
 
        }  
 
        protected void Button1_Click(object sender, EventArgs e)  
        {  
            this.Page.Title = "new title";  
        }  
    }  
0
Jana
Top achievements
Rank 1
answered on 05 Jun 2010, 05:09 PM
anyone test the code?
0
Fiko
Telerik team
answered on 08 Jun 2010, 08:38 AM
Hi Janna,

I have used the provided information and I was able to reproduce the problem that you experience. In your scenario you need to add the control to the RadWindow's content template before the Page_Load event. Please note that the Button_Click event (where you load the user control and add it in the RadWindow's ContentContainer) is fired after the Page_Load event. This is why, I recommend you to do it in the Page_Init event as shown in the attached demo. Then you can still show it when a button is clicked by using  VisibleOnPageLoad="true" property of the RadWindow. The modified code should looks like this:
public partial class Details : System.Web.UI.Page
{
    RadWindow W;
    protected void Page_Init(object sender, EventArgs e)
    {
        W = new RadWindow();
        W.ContentContainer.Controls.Add(this.LoadControl("WebUserControl_Cs.ascx"));
        this.RadWindowManager1.Windows.Add(W);
    }
 
    protected void Button1_Click(object sender, EventArgs e)
    {
        W.VisibleOnPageLoad = true;
    }
}


Regards,
Fiko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jana
Top achievements
Rank 1
answered on 10 Jun 2010, 04:50 PM
i am afraid ... failed :S

i want to load controls in radwindow dynamically at runtime

so it will be in this scenario

when i fire event like button click or somthing first i will add new window then in window content i will load control

control sure can post back , coz it will contains buttons ....etc
0
Fiko
Telerik team
answered on 15 Jun 2010, 10:07 AM
Hello Janna,

I am not quite sure that I understood your scansion. This is why, could you please rework the demo attached to my last response to this thread in order to show your setup, open a new support ticket and send it back? I will check it and do my best to provide a working solution as soon as possible.

Regards,
Fiko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Window
Asked by
Jana
Top achievements
Rank 1
Answers by
Petio Petkov
Telerik team
Jana
Top achievements
Rank 1
Svetlina Anati
Telerik team
Fiko
Telerik team
Share this question
or