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

[Solved] Anyone using a universal DisplayMessage RadWindow?

1 Answer 186 Views
Window
This is a migrated thread and some comments may be shown as answers.
bemara57
Top achievements
Rank 1
bemara57 asked on 17 Apr 2008, 05:46 PM
I'm trying to encapsulate the RadWindow in a global, static method so I can display messages, alerts and errors from anywhere in my web app. I have a MasterPage which sort of complicates things. I'm sure I'm not the first to try to create a univeral DisplayMessage radalert, can anyone share how they've handled this? I'm trying to figure out how to make it more dynamic in terms of templating from within the static method, or maybe even a better way to do this. Also it it a good idea to put a RadWindowManager in the MasterPage?

In my MasterPage I have this:
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" />
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" />

In my aspx content page I have this:
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" />
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
          ...
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

In my aspx.cs content page I have this:
string message = "Deleted user: " + userName;
Globals.DisplayMessage(message, 200, 100, false, this.Page);

In my static method I have this:
        public static void DisplayMessage(string message, int width, int height,
            bool error, Page currentPage)
        {
            string title;

            if (error)
                title = "Error";
            else
                title = "Alert";

            RadAjaxManager.GetCurrent(currentPage).ResponseScripts.Add(
                "radalert('" + message.Replace("'", "\'") +
                "<br />', " + width + ", " + height + ",'" + title + "'); return false;");
        }

1 Answer, 1 is accepted

Sort by
0
Lini
Telerik team
answered on 23 Apr 2008, 08:47 AM
Hi,

I think that the master page is a logical location for the Ajax and Window manager controls.

If you have multiple master pages and you do not want to copy the controls to all masters, then you can put the Ajax and Window controls (along with the DisplayMessage method) in a base page class and make all your master pages inherit from the base class. This way any changes to the DisplayMessage functionality will be made in only one location.

Sincerely yours,
Lini
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Window
Asked by
bemara57
Top achievements
Rank 1
Answers by
Lini
Telerik team
Share this question
or