RadWindow using ContentTemplate and OOP

2 posts, 0 answers
  1. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 03 Nov 2011 Link to this post

    Hi Telerik,

    Got another question for you guys. I've got my own RadWindow class, and it has a design-time control on my page:

    <cs:GlobalSettingsRadWindow ID="DashboardGlobalSettingsWindow" Runat="Server" >
                        <ContentTemplate>
                            <div ID="GlobalSettingsDecorationZone">
                                <fieldset id="RefreshProperties">
                                    <legend>Refresh Settings</legend>
                                    <div id="RefreshArea">
                                        <div id="RefreshLeftSide">
                                            Auto-Refresh Enabled:
                                            <asp:CheckBox ID="AutoRefreshCheckBox" Runat="Server" />
                                        </div>
                                        <div id="RefreshRightSide">
                                            <telerik:RadNumericTextBox ID="AutoRefreshNumericTextBox" Runat="Server" Label="Auto-Refresh Interval (Minutes):" MaxValue="60" MinValue="1" ShowSpinButtons="True" Value="1" Width="225px" Enabled="False" LabelCssClass="riLabel LabelDisabled" DataType="System.Int32">
                                                <NumberFormat DecimalDigits="0" AllowRounding="False" />
                                            </telerik:RadNumericTextBox>
                                        </div>
                                    </div>
                                </fieldset>
     
                                <fieldset id="TabProperties">
                                    <legend>Tab Settings</legend>
                                        <div id="TabPropertiesArea">
                                            <div id="TabLeftSide">
                                                <telerik:RadListBox ID="TabsListBox" Runat="Server" AllowDelete="True" AllowReorder="True" EnableDragAndDrop="True" Height="95px" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" Width="150px" OnClientLoad="OnClientLoad" TabIndex="1" />
                                            </div>
                                            <div id="TabRightSide">
                                                <telerik:RadTextBox ID="TabTextBox" Runat="Server" EmptyMessage="Enter tab name" Width="150px" />
                                                <div id="TabButton">
                                                    <telerik:RadButton ID="TabTextApplyButton" Runat="server" Text="Add Tab" AutoPostBack="False" OnClientClicked="OnButtonClicked">
                                                    </telerik:RadButton>
                                                </div>
                                            </div>  
                                        </div>
                                </fieldset>
     
                                <fieldset id="CycleProperties">
                                    <legend>Tab Cycle Settings</legend>
                                    <div id="CycleArea">
                                        <div id="CycleLeftSide">
                                            Auto-Cycle Enabled:
                                            <asp:CheckBox ID="AutoCycleCheckBox" runat="server" />
                                        </div>
                                        <div id="CycleRightSide">
                                            <telerik:RadNumericTextBox ID="AutoCycleNumericTextBox" Runat="server" Label="Auto-Cycle Interval (Minutes):" MaxValue="60" MinValue="1" ShowSpinButtons="True" Value="1" Width="225px" Enabled="False" LabelCssClass="riLabel LabelDisabled" DataType="System.Int32">
                                                <NumberFormat DecimalDigits="0" AllowRounding="False" />
                                            </telerik:RadNumericTextBox>
                                        </div>
                                    </div>
                                </fieldset>
     
                                <div id="BottomButton">
                                    <telerik:RadButton ID="ApplyGlobalSettingsButton" Runat="server" Text="Apply" AutoPostBack="False" OnClientClicked="CloseAndSave"/>
                                </div>
                            </div>
                        </ContentTemplate>
                    </cs:GlobalSettingsRadWindow>

    Now, I work on it's children controls in Page_Init:

    private void InitializeGlobalSettings()
    {
        //Global Settings Window Code.
        GlobalSettings globalSettings = StateManager.GetStates<GlobalSettings>();
     
        if (globalSettings.RefreshEnabled)
        {
            AutoRefreshCheckBox.Checked = true;
            AutoRefreshNumericTextBox.Value = globalSettings.RefreshInterval;
            AutoRefreshNumericTextBox.LabelCssClass = "LabelEnabled";
            AutoRefreshNumericTextBox.Enabled = true;
        }
     
        TabsListBox.Items.Clear();
        foreach (RadTab tab in LayoutManager.Instance.TabStrip.Tabs)
        {
            TabsListBox.Items.Add(new RadListBoxItem {Text = tab.Text, Value = tab.Value});
        }
     
        if (globalSettings.CycleEnabled)
        {
            AutoCycleCheckBox.Checked = true;
            AutoCycleNumericTextBox.Value = globalSettings.CycleInterval;
            AutoCycleNumericTextBox.LabelCssClass = "LabelEnabled";
            AutoCycleNumericTextBox.Enabled = true;
        }
    }

    This function is defined in MyPage.aspx.cs, not GlobalSettingsRadWindow.cs. This is necessary because I need to be able to have a handle on the CheckBoxes and various other controls.

    I'd really like to fix this, though, as the controls are relevant to the RadWindow and not to the page.

    Is there an easy way to do something like this without coupling the Page to the RadWindow class? Thinking along the lines of adding the controls to the RadWindow inside of its constructor, but how can I handle all of the various HTML markup which is not a System.Web.UI control?

    Thanks

    Sean


  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 04 Nov 2011 Link to this post

    Hi Sean,

    I suggest you simply use e WebUserControl for your markup and place it in a regular RadWindow's ContentTemplate. Thus you will get access to the controls in the code-behind of the page, you will get the regular ASP page lifecycle and I believe this will make things easier overall.


    Best wishes,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top