Home / Community & Support / Knowledge Base / RadControls for ASP.NET and ASP.NET AJAX / FileExplorer / Change the templates of the predefined dialogs (radalert, radconfirm and radprompt)

Change the templates of the predefined dialogs (radalert, radconfirm and radprompt)

Article Info

Rating: 5

Article information

Article relates to

 RadFileExplorer for ASP.NET AJAX

Created by

 Fiko

Last modified

 September 24, 2010

Last modified by

 Fiko


HOW TO
Change the templates of the predefined dialogs shown in RadFileExplorer control.

DESCRIPTION
This article shows how to set new templates for the radconfirm, radalert and radprompt dialogs shown in RadFileExplorer control. The provided solution allows introducing a completely new look and feel of the dialogs.




SOLUTION
  The predefined dialogs' templates can be changed by assigning the desired templates to the corresponding template properties of the RadWindowManager embedded in the RadFileExplorer. The manager can be accessed by using the WindowManager property of the RadFileExplorer control.

The example bellow goes through all the steps in order to change the alert template:
  1. Add a new class to the App_Code folder. Name the class AlertTemplate - it should inherit the ITemplate interface:

    C#
    public class AlertTemplate : ITemplate
    {
        private Page _page;
     
        public AlertTemplate(Page page)
        {
            this._page = page;
        }
     
        void ITemplate.InstantiateIn(Control owner)
        {
            Control ctrl = _page.LoadControl("~/Controls/AlertTemplate.ascx");
            owner.Controls.Add(ctrl);
        }
    }

    VB.NET
    Public Class AlertTemplate
        Implements ITemplate
        Private _page As Page
     
        Public Sub New(page As Page)
            Me._page = page
        End Sub
     
        Private Sub ITemplate_InstantiateIn(owner As Control) Implements ITemplate.InstantiateIn
            Dim ctrl As Control = _page.LoadControl("~/Controls/AlertTemplate.ascx")
            owner.Controls.Add(ctrl)
        End Sub
    End Class
  2. Create AlertTemplate.ascx user control which contains the new template. The template should be prepared based on the information provided in this help article.

    AlertTemplate.ascx's content for the alert template:
    <div id="RadWindowManager1_alerttemplate">
        <div class="windowpopup radalert">
            <div class="dialogtext">
                <div style="color:Red;">CUSTOM RADALERT TEMPLATE :</div> {1}
            </div>
            <div>
                <a onclick="$find('{0}').close();" class="radwindowbutton" href="javascript:void(0);">
                    <span class="outerspan"><span class="innerspan">##LOC[OK]##</span> </span></a>
            </div>
        </div>
    </div>
  3. The same should be done for the rest of the templates. Then the new templates should be assigned to the corresponding RadWindowManager's properties:

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadFileExplorer1.WindowManager.AlertTemplate = new AlertTemplate(this.Page);
        RadFileExplorer1.WindowManager.ConfirmTemplate = new ConfirmTemplate(this.Page);
        RadFileExplorer1.WindowManager.PromptTemplate = new PromptTemplate(this.Page);
    }

    VB.NET:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        RadFileExplorer1.WindowManager.AlertTemplate = New AlertTemplate(Me.Page)
        RadFileExplorer1.WindowManager.ConfirmTemplate = New ConfirmTemplate(Me.Page)
        RadFileExplorer1.WindowManager.PromptTemplate = New PromptTemplate(Me.Page)
    End Sub

Comments

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.