set radwindow size in percent

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 21 Aug 2013 Link to this post

    Trying to set the radwindow to a percent of the screen size.  This way the user still knows its  a pop-up window and has to be closed apporpriately instead of thinking its a real window, found an example online but it does not work, so I though Telerik has done this somewhere, so here I am asking the question.

    Here is what I have but nothing works.  I need to set it at about 90% of the screen size.

    function SelectedName(source, eventArgs) {
                var txt = eventArgs.get_text();
                var val = eventArgs.get_value();
                var radWidow = $find("<%= RadWindow.ClientID%>");
                var textbox = document.getElementById("<%=txtSearch.ClientID%>");
     
                if (val == '') {
                    alert('You must pick a recruit from drop down list.');
                }
                else {
                    radWidow.show();
                    radWidow.setUrl("ManageProcessor.aspx?Pass=" + val);
                    var browserWidth = $telerik.$(window).width();
                    var browserHeight = $telerik.$(window).height();
                    radWidow.setSize(Math.ceil(browserWidth * value / 100), Math.ceil(browserHeight * value / 100));
                    radWidow.center();
                    textbox.value = '';
                }
               }
     
            function VerifyEnlist() {
                var Enlist = document.getElementById("<%=ddlEnlistment.ClientID%>").value;
                var radWidow = $find("<%= RadWindow.ClientID%>");
                if (Enlist == 4) {
                    radWidow.show();
                    radWidow.setUrl("WoTracker.aspx");
                    var browserWidth = $telerik.$(window).width();
                    var browserHeight = $telerik.$(window).height();
                    radWidow.setSize(Math.ceil(browserWidth * value / 100), Math.ceil(browserHeight * value / 100));
                    radWidow.center();
                }
                else {
                    radWidow.show();
                    radWidow.setUrl("ManageProcessor.aspx?Type=" + Enlist);
                    var browserWidth = $telerik.$(window).width();
                    var browserHeight = $telerik.$(window).height();
                    radWidow.setSize(Math.ceil(browserWidth * value / 100), Math.ceil(browserHeight * value / 100));
                    radWidow.center();
                }
            }

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Aug 2013 Link to this post

    Hi Kevin,

    Please have a look at the following JavaScript code I tried to set the RadWindow size to 90% of its parent window size. Also note that by design, the RadWindow control does not accept values in percent and you need to use fixed values in its declaration.

    ASPX:
    <telerik:RadButton ID="RadButton1" runat="server" Text="Open RadWindow" OnClientClicked="openRadWindow"
        AutoPostBack="false">
    </telerik:RadButton>
    <telerik:RadWindow ID="RadWindow1" runat="server" NavigateUrl="http://www.telerik.com">
    </telerik:RadWindow>

    JavaScript:
    <script type="text/javascript">
        var $ = $telerik.$;
        var radwindow;
     
        function pageLoad() {
            radwindow = $find("<%= RadWindow1.ClientID%>");
        }
     
        function openRadWindow() {
            radwindow.show();
            setWindowsize();
        }
     
        $(window).resize(function () {
            if (radwindow.isVisible()) {
                setWindowsize();
            }
        });
     
        function setWindowsize() {
            var viewportWidth = $(window).width();
            var viewportHeight = $(window).height();
            radwindow.setSize(Math.ceil(viewportWidth * 90 / 100), Math.ceil(viewportHeight * 90 / 100));
            radwindow.center();
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top