Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Window > Controlling alert, confirm, prompt window size
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Controlling alert, confirm, prompt window size

Feed from this thread
  • Tod Golding Intermediate avatar

    Posted on Mar 5, 2006 (permalink)

    Is there any way to control the size of the window that is used to house alert, confirm, and prompt dialogs. I know how to control the formatting of the window contents, but I can't seem to find a way to change the size of the overall window. Thanks for your help.

  • Georgi Tunev Georgi Tunev admin's avatar

    Posted on Mar 6, 2006 (permalink)

    Hi Tod,

    You can control the dimensions of the window by providing the appropriate arguments in the radalert method:

    radalert('Welcome to r.a.d.<b>window</b>!', 300, 200)




    Kind regards,
    Georgi Tunev
    the telerik team

  • Binay avatar

    Posted on Jun 27, 2011 (permalink)

    In order to control the width and height of radalert and radconfirm, do the following:

    1) Add the following markup in your aspx page or in your master page.

     <form id="form1" runat="server">  
         <!--The span ruler is placeholder to temporarily hold message to calculate width and height -->
         <span id="ruler" style="visibility: hidden; white-space: nowrap;"></span>


    2) Add following script into your page or Master Page.
     <script language="javascript" type="text/javascript">
            function calculateWidthHeight(message, widthObj, heightObj) {

                var fontHeight = 12;
                width = 250;
                heightObj.height = 100;


                widthObj.width = message.visualLength();
                if (widthObj.width > 400)
                {
                    heightObj.height = heightObj.height + (fontHeight * widthObj.width / 400);
                    widthObj.width = 400;
                }
                else
                {
                    widthObj.width =  widthObj.width+ 100;
                }
            }
            

            function ShowAlert(Title,Message) {
                var heightObj = new Object();
                heightObj.height = 0;
                var widthObj = new Object();
                widthObj.width = 0;
                calculateWidthHeight(Message, widthObj, heightObj);
                radalert(Message, widthObj.width, heightObj.height, Title);
            }

            function ShowConfirm(Title, Message,CallbackFunction) {
                var heightObj = new Object();
                heightObj.height = 0;
                var widthObj = new Object();
                widthObj.width = 0;
                calculateWidthHeight(Message, widthObj, heightObj);
                radconfirm(Message, CallbackFunction, widthObj.width, heightObj.height, null, Title);
            }

            String.prototype.visualLength = function () {
                var ruler = document.getElementById("ruler");
                ruler.innerHTML = this;
                return ruler.offsetWidth;
            }
        </script>


    3) Now you can call ShowAlert() or ShowConfirm() method
    say:
     <input type="button" value="Show Alert" onclick="ShowAlert('My Alert Title','My Alert Message, this can be any length')"  />
        <input type="button" value="Show Confirm" onclick="ShowConfirm('My confirm Title','My descrition, can be any length',null)" />

    4) Of course you need to add ScriptManager and RadWindow to your page.

    Cheers
    Binay Rana
    Nepal


Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Window > Controlling alert, confirm, prompt window size