470,628 Members | 2,328 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,628 developers. It's quick & easy.

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 4427
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Alex Maghen | last post: by
2 posts views Thread by Argirop | last post: by
8 posts views Thread by Frank | last post: by
4 posts views Thread by faraz | last post: by
10 posts views Thread by =?Utf-8?B?RGFuaQ==?= | last post: by
reply views Thread by Tommy Jakobsen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.