Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6753733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:11:50+00:00 2026-05-26T13:11:50+00:00

I got a js function that is defined in a JScript.js file. This file

  • 0

I got a js function that is defined in a JScript.js file. This file is defined on the masterpage. I am trying to call the sayhello function in this file from the inIframe.aspx page. This inIframe.aspx ‘runs’ inside the webform1.aspx page and the webform1.aspx page has a masterpage called masterWithJs.master.

when I hit :

http://localhost:8022/inIframe.aspx

I get an script error in firebug:

window.parent.sayhello is not a function

masterpage:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="masterWithJs.master.cs"
    Inherits="IFrameJS.masterWithJs" %>

<!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></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
        <script src="Scripts/JScript1.js" type="text/javascript"></script>
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

webform1.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/masterWithJs.Master" AutoEventWireup="true"
    CodeBehind="WebForm1.aspx.cs" Inherits="IFrameJS.WebForm1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <iframe id="myIframe" runat="server"></iframe>
</asp:Content>

inIframe.aspx

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

<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        this is the iframe page
    </div>
    </form>
    <script type="text/javascript">
        window.parent.sayhello();
    </script>
</body>
</html>

JScript1.js

function sayhello() {
    alert( 'hello');
}

webform1.aspx behindcode:

 public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            myIframe.Attributes.Add("src","inIframe.aspx");
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:11:51+00:00Added an answer on May 26, 2026 at 1:11 pm

    Well Then i think i know the solution

    Try to create a utility function for the path of the script holding the function you call
    like this one

       public static string ReferenceScript(string scriptFile)
        {
            //this line is just an example "~/include/js/" of the path of the js file
            var filePath = VirtualPathUtility.ToAbsolute("~/include/js/" + scriptFile);
            return "<script type=\"text/javascript\" src=\"" + filePath + "\"></script>";
        }
    

    and then call it in the master page HTML
    in the beginning of the body

    //EtPortalEntities.um_utility is an instanse of my name space you should put yours
    <%= EtPortalEntities.um_utility.ReferenceScript("jquery.js")%>
    

    and then try i think it should work if its all about paths as i think

    Regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a function that does (in short): my $file = IO::File->new(| some_command >>
I've got a javascript function I created. Somewhere in that function, this line is
In external (Delphi-created) DLL I've got the following function that I need to call
I got a Function that returns a Collection<string> , and that calls itself recursively
I've got a function that runs a user generated Regex. However, if the user
I've got a function here that is meant to look through a list of
I've got one function checkEvery15Seconds that runs every 15 seconds. It checks to see
I've got a view function that has to decide which form to use depending
Anyone got a ready made function that will take an XML string and return
I've got some data (the output of a ddply function) that I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.