Object Expected Error

3 posts, 0 answers
  1. Maheshkumar
    Maheshkumar avatar
    1 posts
    Member since:
    Oct 2012

    Posted 12 Oct 2012 Link to this post

    I am trying to open a RadWindow in client side after i click the button but it gives the error: object expected
    it doesn't calls the javascript method(openWin2()) to open the new RadWindow

    Below is my code

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Dialog1.aspx.cs" Inherits="Telerik_Sample.Dialog1" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>The Eruption</title>
        <style type="text/css">
            html, body, form
            {
                padding: 0;
                margin: 0;
                height: 100%;
                background: ##797979;
            }
            
            body
            {
                font: normal 11px Arial, Verdana, Sans-serif;
            }
            fieldset
            {
                height: 150px;
            }
        </style>
    </head>
    <body onload="AdjustRadWidow">
        <form id="form1" runat="server">
        <!--RadScript Manager-->
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>    
            <script type="text/javascript">
                function GetRadWindow() {
                    var oWindow = null;
                    if (window.radWindow) oWindow = window.radWindow;
                    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                    return oWindow;
                }

                function AdjustRadWidow() {
                    var oWindow = GetRadWindow();
                    setTimeout(function () { oWindow.autoSize(true); if ($telerik.isChrome || $telerik.isSafari) ChromeSafariFix(oWindow); }, 500);
                }

                //fix for Chrome/Safari due to absolute positioned popup not counted as part of the content page layout
                function ChromeSafariFix(oWindow) {
                    var iframe = oWindow.get_contentFrame();
                    var body = iframe.contentWindow.document.body;

                    setTimeout(function () {
                        var height = body.scrollHeight;
                        var width = body.scrollWidth;

                        var iframeBounds = $telerik.getBounds(iframe);
                        var heightDelta = height - iframeBounds.height;
                        var widthDelta = width - iframeBounds.width;

                        if (heightDelta > 0) oWindow.set_height(oWindow.get_height() + heightDelta);
                        if (widthDelta > 0) oWindow.set_width(oWindow.get_width() + widthDelta);
                        oWindow.center();

                    }, 310);

                    function openWin2() {
                        var parentPage = GetRadWindow().BrowserWindow;
                        var parentRadWindowManager = parentPage.GetRadWindowManager();
                        var oWnd2 = parentRadWindowManager.open("Dialog2.aspx", "RadWindow2");
                        window.setTimeout(function () {
                            oWnd2.setActive(true);
                        }, 0);
                    }

                    function returnToParent() {
                        //create the argument that will be returned to the parent page
                        var oArg = new Object();

                        //get the city's name
                        oArg.cityName = document.getElementById("cityName").value;

                        //get the selected date from RadDatePicker
                        var datePicker = $find("<%= Datepicker1.ClientID %>");
                        oArg.selDate = datePicker.get_selectedDate().toLocaleDateString();

                        //get a reference to the current RadWindow
                        var oWnd = GetRadWindow();

                        //Close the RadWindow and send the argument to the parent page
                        if (oArg.selDate && oArg.cityName) {
                            oWnd.close(oArg);
                        }
                        else {
                            alert("Please fill both fields");
                        }
                    }

                }</script>    
        <div>
            <fieldset id="fld1">
                <legend>Travel Plan</legend><span style="margin: 6px 0 0 18px;">Choose date:</span>
                <telerik:RadDatePicker ID="Datepicker1" Skin="Sunset" runat="server" Width="140">
                    <ClientEvents OnPopupOpening="AdjustRadWidow" OnPopupClosing="AdjustRadWidow"/>
                </telerik:RadDatePicker>
                <div style="margin: 20px 0 0 0;">
                    <div style="float: left; margin: 6px 0 0 18px;">
                        Choose City:</div>
                    <input type="text" style="width: 100px;" id="cityName" value="Sofia" />                
                   <button onclick="openWin2(); return false;" title="Choose City"> // the error is shown in this line
                        ...</button>
                </div>
            </fieldset>
            <div style="margin-top: 4px; text-align: right;">
                <button title="Submit" onclick="returnToParent(); return false;" >
                    Submit</button>
            </div>
        </div>
        </form>
    </body>
    </html>

  2. <span>w</span>
    <span>w</span> avatar
    84 posts
    Member since:
    Jun 2012

    Posted 13 Oct 2012 Link to this post

    My Dear, If you want to open Radwindow on client side use this code.
    1. Open Radwindow on Button
    2. Open RAdwindow on LinkButton
    3. Open Radwindow on ImageButton


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Open RadWindow on Client side</title>
        
        <script language="javascript">
                 function openRatingWin(url) {
                     window.scrollTo(0, 0);
                     var oWnd = radopen(url, "PrintWindow");
                 }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
            </telerik:RadScriptManager>
        <div>
                <asp:Button ID="btn" runat="server" OnClientClick="openRatingWin('Test.aspx'); return false;" Text="Open RadWindow on Button" />
                <br />
                <asp:LinkButton ID="lnkButton" runat="server" OnClientClick="openRatingWin('Test.aspx'); return false;" Text="Open RadWindow on LinkButton"></asp:LinkButton>
                <br />
                <asp:ImageButton ID="imgButton" runat="server" OnClientClick="openRatingWin('Test.aspx'); return false;" ImageUrl="~/Images/add.png" />
                <br />
                <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false" Width="100%"
                ReloadOnShow="true" BackColor="Gray" runat="server" Modal="true" Skin="Default" EnableShadow="true">
                  <Windows>
                    <telerik:RadWindow ID="PrintWindow" Width="870px" Height="480px" runat="server" VisibleStatusbar="false" Behaviors="Close,Maximize,Minimize" >
                    </telerik:RadWindow>
                  </Windows>      
                </telerik:RadWindowManager>
        </div>
        </form>
    </body>
    </html>

    Regards
    Muhammad Waseem
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. <span>w</span>
    <span>w</span> avatar
    84 posts
    Member since:
    Jun 2012

    Posted 13 Oct 2012 Link to this post

    My Dear, Open Radwindow on client side,
    1 . Open Radwindow on Button click
    2 Open Radwinow on LinkButton Click
    3. Open Radwindow on ImageButton Click

    <script language="javascript">
                 function openRatingWin(url) {
                     window.scrollTo(0, 0);
                     var oWnd = radopen(url, "PrintWindow");
                 }
    </script>

    <asp:Button ID="btn" runat="server" OnClientClick="openRatingWin('Test.aspx'); return false;" Text="Open RadWindow on Button" />
    <asp:LinkButton ID="lnkButton" runat="server" OnClientClick="openRatingWin('Test.aspx'); return false;" Text="Open RadWindow on LinkButton"></asp:LinkButton>
    <asp:ImageButton ID="imgButton" runat="server" OnClientClick="openRatingWin('Test.aspx'); return false;" ImageUrl="~/Images/add.png" />
    <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false" Width="100%"
                ReloadOnShow="true" BackColor="Gray" runat="server" Modal="true" Skin="Default" EnableShadow="true">
                  <Windows>
                    <telerik:RadWindow ID="PrintWindow" Width="870px" Height="480px" runat="server" VisibleStatusbar="false" Behaviors="Close,Maximize,Minimize" >
                    </telerik:RadWindow>
                  </Windows>      
    </telerik:RadWindowManager>

    Regards
    Muhammad Waseem
Back to Top