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

Declaring RadWindow on BasePage class

2 Answers 39 Views
Window
This is a migrated thread and some comments may be shown as answers.
Bader
Top achievements
Rank 1
Bader asked on 16 Aug 2011, 06:25 PM

Hello,

I have the following code which declares a radwindow in BasePage class, its works fine in aspx pages, but I can't use it in User Controls and Master Pages:

string BaseRadWindowID
        {
            get
            {
                return "UniqueBaseRadWindowID";
            }
        }
 
        RadWindow window = new RadWindow();// Create a enw Window
 
        RadWindow BaseRadWindow
        {
            get
            {
                return window;
            }
        }
 
        protected override void OnInit(EventArgs e)
        {
            this.window = new RadWindow();// Create a enw Window
            window.ID = BaseRadWindowID;// the id of the RadWindow;
            this.Form.Controls.Add(window);// Add it to the page
            base.OnInit(e);
        }
 
        public void ShowBaseRadWindow(bool visibleOnPageLoad, string navigationUrlQueryString)
        {
            BaseRadWindow.Width = Unit.Pixel(450);
            BaseRadWindow.Height = Unit.Pixel(150);
            BaseRadWindow.VisibleOnPageLoad = true;
            BaseRadWindow.VisibleStatusbar = true;
            BaseRadWindow.ReloadOnShow = true;
            BaseRadWindow.Modal = true;
            BaseRadWindow.Behaviors = WindowBehaviors.Close;
            BaseRadWindow.Style.Add("z-index", "10000");
            BaseRadWindow.NavigateUrl = "~/Pages/Messages/Default.aspx" + navigationUrlQueryString;
            BaseRadWindow.VisibleOnPageLoad = visibleOnPageLoad;
        }

I call the window in the aspx pages in this way:

this.ShowBaseRadWindow(true, string.Empty);

Please, I need your help in order to call the window and show it in User Controls and Master Pages.
It is very appreciated to send me the modified code.

Regards,
Bader

2 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 18 Aug 2011, 01:50 PM
Hi Bader,

The RadWindow is a client-side object and is thus best used with JavaScript. What you are attempting to do (setting the VisibleOnPageLoad property to true) will often result in the unexpected behavior where a postback from another element will result in the RadWindow reopening. What I would recommend is that you inject a JavaScript function from the server-side that will open a RadWindow that is already declared in a RadWindowManager, present in the master page. You could also use radopen(url, "RadWindowName") to easily set the NavigateUrl. A simple example showing this approach can be found in the attached archive. You could, of course, externalize this method in a class in the App_Code folder, or as a public method in a base class, whatever fits your needs. I hope this helps.


Best wishes,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Bader
Top achievements
Rank 1
answered on 18 Sep 2011, 04:53 PM

Hello,

Thank you very much for your reply, it was really helpful in some cases.
There is only one problem (Depending on the code you attached in your last post):
Open the radwindow, close it and refresh the web page and you will se that the radwindow will open automatically (Its looks like that the code which opens the radwindow called by refreshing the web page).

Please, I need your help in order to prevent displaying the RadWindow by refresh the web page.
It is very appreciated to send me the modified code.

Regards,
Bader

Tags
Window
Asked by
Bader
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Bader
Top achievements
Rank 1
Share this question
or