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

Problem in AutoSizing RadWindow

1 Answer 135 Views
Window
This is a migrated thread and some comments may be shown as answers.
Kapil Lavangade
Top achievements
Rank 1
Kapil Lavangade asked on 11 Dec 2009, 05:31 AM
Hello All,              
             We have used "autosize=true" for radwindow, but the radwindow is not getting autosized after the content on the page changes instead the horizontal and vertical scrollbars are coming. We are using AjaxPanel.
As you have specified that "The size of the content page is taken in window.onload. This means that if you change the size of the content page with Ajax, the RadWindow will not resize after the new content is displayed.".
 Can you please tell us know where the problem is?
           We have also tried with the following code on the Page_Load(). It is helping in autosizing, but on the continuous button clicks the size of the  rad window grows horizontally till the end of the browser reaches.

  #region RadWindow AutoSize
        public void EnableRadWindowAutoSize(RadAjaxPanel radAjaxPanel, Label messageLabel)
        {
            radAjaxPanel.Controls.Add(SetRadWindowSizeRadScriptBlock(messageLabel));
        }
        public void EnableRadWindowAutoSize(RadAjaxManager radAjaxManager, Label messageLabel)
        {
            radAjaxManager.Controls.Add(SetRadWindowSizeRadScriptBlock(messageLabel));
        }
        private RadScriptBlock SetRadWindowSizeRadScriptBlock(Label messageLabel)
        {
            RadScriptBlock radScriptBlock = new RadScriptBlock();
            System.Text.StringBuilder scriptContent = new System.Text.StringBuilder();
            scriptContent.Append(@"
             <script type='text/javascript'>  
                function SetRadWindowSize(messageLabelID)
                {
                    try
                   {
                    var messageLabel = document.getElementById(messageLabelID);
                    if (messageLabel)
                      {                
                        if (messageLabel.innerHTML.length > 0)
                        {
                         var oWindow = null;
                         if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                         else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz az well)
                         oWindow.autoSize();
                        }
                     }
                  }
                  catch (ex){}
              }");
            scriptContent.Append(String.Format("SetRadWindowSize('{0}')</script>", messageLabel.ClientID));
            radScriptBlock.Controls.Add(new LiteralControl(scriptContent.ToString()));
            return radScriptBlock;
        }
   #endregion

Please let us know if you have any solution.
Thanks,

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 16 Dec 2009, 01:09 PM
Hi Kapil Lavangade,

 I assume that the problem comes from the manner you have used to execute the script - you can test with an alert message whether the script is called. The correct way to execute a script from the server is explained in details below:

http://blogs.telerik.com/blogs/posts/09-05-05/executing_javascript_function_from_server-side_code.aspx


Greetings,
Svetlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Window
Asked by
Kapil Lavangade
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or