473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to put Javascript in a page using masterpage

Hi,

I have a page which use a masterpage.
And I put a javascript in this page like below:

<%@ Page Language="C#" MasterPageFile="~/SITE.master"
CodeFile="TEST.aspx.cs" Inherits="TEST_aspx" Title="TEST Javascript" %>
<script type="text/javascript" language="javascript">
DOING SOMETHING WITH OBJECTS THAT EXIST ONLY IN TEST PAGE
BUT NOT IN MASTER PAGE

}
</script>
<asp:content contentplaceholderid="PageContent" runat="Server">
.......
But I hit the error, Error:
Validation (XHTML 1.0 Transitional): Content is not supported outside
'script' or 'asp:content' regions.

It will cause error "Object not found" as these objects do not exist in
master page if I put this javascript into my masterpage.

How to solve this problem?

Thanks
-Rockdale
I tried to put this javascript

Sep 1 '06 #1
1 4504
following the directions in the error, and place the script inside the
<asp:contenttag. because you are using content area and a master page, the
id will be prefixed with the master and content area names. you should use
ClientId to get the actual rendered names.

-- bruce (sqlwork.com)
"rockdale" <ro************@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
Hi,

I have a page which use a masterpage.
And I put a javascript in this page like below:

<%@ Page Language="C#" MasterPageFile="~/SITE.master"
CodeFile="TEST.aspx.cs" Inherits="TEST_aspx" Title="TEST Javascript" %>
<script type="text/javascript" language="javascript">
DOING SOMETHING WITH OBJECTS THAT EXIST ONLY IN TEST PAGE
BUT NOT IN MASTER PAGE

}
</script>
<asp:content contentplaceholderid="PageContent" runat="Server">
......
But I hit the error, Error:
Validation (XHTML 1.0 Transitional): Content is not supported outside
'script' or 'asp:content' regions.

It will cause error "Object not found" as these objects do not exist in
master page if I put this javascript into my masterpage.

How to solve this problem?

Thanks
-Rockdale
I tried to put this javascript

Sep 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex Maghen | last post by:
Hi. I'm a little confused about the code that resides in the code-behind of a MasterPage and the code that resides in the code-behind of the actual pages that USE that MasterPage. I'm noticing,...
2
by: Argirop | last post by:
I have a page Default.aspx. Its first line is the following: <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="default.aspx.cs"...
8
by: Frank | last post by:
Hi, I am working with VS.NET 2005 Ultimately, I wish to call a JavaScript function from a .js file
4
by: faraz | last post by:
I have a javascript function that i want to call masterpage load method called. I cant add onLoad event of body or table in master page. I have put the call to script function in <form>, it...
0
by: e_spork | last post by:
I am using Page.ClientScript.RegisterStartupScript to throw up a Javascript alert box. When I click OK on the alert box, all the controls on my page disappear and I don't understand why. I can...
2
by: baburk | last post by:
Hi all, when I call the javascript method from code behind file of the same page it works fine. ScriptManager.RegisterClientScriptBlock(this, Page.GetType(), "Scroll",...
10
by: =?Utf-8?B?RGFuaQ==?= | last post by:
Hi, Trying to create a master page that holds a menu, and the menu switches between pages in the site. 2 problem arrosed: a. When I navigate from page to page (all AJAX Web Forms, with the...
2
Frinavale
by: Frinavale | last post by:
JavaScript in ASP.NET Using JavaScript in ASP.NET pages can make your application seem to work faster and prevent unnecessary calls to the server. JavaScript can be used to perform client-side...
0
by: Tommy Jakobsen | last post by:
Hi. Is there a problem when trying to use Javascript on a nested masterpage? On my masterpage, i've got this in the <head>: <asp:ContentPlaceHolder ID="HeadContent" runat="server" /> And on...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.