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

External javascript file problem

2 Answers 132 Views
Window
This is a migrated thread and some comments may be shown as answers.
Bader
Top achievements
Rank 1
Bader asked on 20 Aug 2011, 08:26 PM
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 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Aug 2011, 06:10 AM
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.
0
Bader
Top achievements
Rank 1
answered on 22 Aug 2011, 03:46 PM
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
Tags
Window
Asked by
Bader
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Bader
Top achievements
Rank 1
Share this question
or