External javascript file problem

3 posts, 0 answers
  1. Bader
    Bader avatar
    215 posts
    Member since:
    Aug 2008

    Posted 20 Aug 2011 Link to this post

    Hello,

    I have a problem in using a javascript function which is intended to close a radwindow control.
    If I set the javascript directly into the page (see the following code), then the radwindow will be closed by clicking the Close button, but if I set the javascript code in into an external javascript file then I will get a web page error "Error: The value of the property 'Close' is null or undefined, not a Function object".

    Here is my page code when the javascript is included into the head ContentPlaceHolder:
    <%@ Page Title="<%$ Resources:RLResource, PagesRWForgottenPasswordTitle %>" Language="C#" MasterPageFile="~/Common/MasterPages/BaseMasterPage.master" AutoEventWireup="true" CodeFile="rwForgottenPassword.aspx.cs" Inherits="GeneralNS.RL_Pages_rwForgottenPassword" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
       <script type="text/javascript">
           //Get RadWindow
           function GetRadWindow() {
               var oWindow = null;
               if (window.radWindow)
                   oWindow = window.radWindow;
               else if (window.frameElement.radWindow)
                   oWindow = window.frameElement.radWindow;
               return oWindow;
           }
     
           //Close RadWindow
           function Close() {
               GetRadWindow().Close();
           }
       </script>
    </asp:Content>
     
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Panel ID="TopCloseLinkButtonPanel" runat="server" HorizontalAlign="<%$ Resources:RLResource, NoContentFloat %>" >
            <asp:Label ID="excuteWindowClose" runat="server" Width="410px"></asp:Label>
            <asp:LinkButton ID="TopCloseLinkButton" runat="server" Text="<%$ Resources:RLResource, PagesRWForgottenPasswordTopCloseLinkButton %>" OnClick="CloseLinkButton_Click" ></asp:LinkButton>
    </asp:Panel>
    </asp:Content>

    c# code:
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
    using System.Linq;
    using System.Xml;
    using System.Xml.Linq;
     
    namespace GeneralNS
    {
        public partial class RL_Pages_rwForgottenPassword : BasePage
        {
            protected void Page_Load(object sender, EventArgs e)
            {
               
            }
     
           //Close the forgotten password radwindow
            protected void CloseLinkButton_Click(object sender, EventArgs e)
            {
                excuteWindowClose.Text = "<script type='text/javascript'>Close();</" + "script>";
            }
        }
    }

    Here is head ContentPlaceHolder content when the javascript is included into an external javascript file:
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script src="http://localhost:53965/abcde.com/Common/Design/Javascript/General.js" type="text/javascript"></script>
    </asp:Content>


    Note: the javascript code which is apears in the first code block (above) is exists in the  General.js file.

    Please, I need your help in order to solve the above problem and to able to set radwindow javascript code into an external file.
    It is very appreciated to send me the modified code.

    Regards,
    Bader
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Aug 2011 Link to this post

    Hello Bader,

    Try the following code snippet to close a RadWindow Control.
    protected void CloseLinkButton_Click(object sender, EventArgs e)
      {
           Page.ClientScript.RegisterStartupScript(this.GetType(), "", "Close()", true);
      }

    Thanks,
    Shinu.
  3. Bader
    Bader avatar
    215 posts
    Member since:
    Aug 2008

    Posted 22 Aug 2011 Link to this post

    Hello,

    Thank you for your reply, unfortunately, you suggested solution doesn't help, I still get the same web page error "Error: The value of the property 'Close' is null or undefined, not a Function object"

    Please I need your help,

    Regards,
    Bader
Back to Top