473,509 Members | 2,946 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use Java Script File with Asp.Net page that uses a Master page.

I'm using some Java Script I found that supports a 'back' button on my
ASP.Net page. The Asp.Net page uses a Master page. I thought I'd put the
Java Script in a Java Script file [.js]. The thought was that I could use
this script in other pages. So I put a reference to the script file in the
<head tag of the Master page. But that does not work because the <head tag
of the Master page also contains a 'runat=server' statement. And only one
<head statement is allowed.

Next I tried referencing the script file in the Asp.Net page and I get an
'Error on page' message at run time when I click the 'back' button. If I put
the script in the asp.net page then it works fine.

Is there a way to reference a script file in an asp.net page that uses a
master page?

Cheers,
Larry Rebich
Dec 1 '06 #1
1 3099
Hello Larry,

You should be able to place a reference to a .js file in the masterpage.
Something like the following:

<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<head runat="server">
<title>Untitled Page</title>
<link rel="stylesheet" type="text/css" href="~/stylesheet.css"/>
<script type="text/javascript" src="~/jscript.js"></script>
</head>

Not exactly sure why it isn't working for you. Scott over at OdeToCode.com
has written a nice article on MasterPages: Tips, Trickes,and Traps. Well
worth looking into if you haven't already:
http://www.odetocode.com/Articles/450.aspx.

--
cheers - brians
http://www.limbertech.com
"Larry Rebich" wrote:
I'm using some Java Script I found that supports a 'back' button on my
ASP.Net page. The Asp.Net page uses a Master page. I thought I'd put the
Java Script in a Java Script file [.js]. The thought was that I could use
this script in other pages. So I put a reference to the script file in the
<head tag of the Master page. But that does not work because the <head tag
of the Master page also contains a 'runat=server' statement. And only one
<head statement is allowed.

Next I tried referencing the script file in the Asp.Net page and I get an
'Error on page' message at run time when I click the 'back' button. If I put
the script in the asp.net page then it works fine.

Is there a way to reference a script file in an asp.net page that uses a
master page?

Cheers,
Larry Rebich
Dec 2 '06 #2

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

Similar topics

7
3362
by: Venturer | last post by:
I have a banner script that is included in php on a website but the actual script is hosted on a different site allowing me to only edit one file to update the script. I need to store in a...
3
2273
by: Mark Olbert | last post by:
I have some img tags on a master page which reference files in a top-level directory. They look like this: <img src="assets/test.gif" id="gnr" /> assets is a subdirectory of the website root. ...
1
9586
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
7
1502
by: McGeeky | last post by:
Hi. I have a page that is based on a master page. But how do I tell this page to use a CSS file using the LINK tag in the HEAD tag when the master page has this declaration in it? -- McGeeky...
8
2372
by: dbaplusplus | last post by:
I worked on web development using java script many many years, so I am now a newbie to javascript. I have a single html page, which is generated dynamically using some programming language. Web...
7
3168
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
1
2660
by: anilkumar1980 | last post by:
Hi All, Here I need help to all of u, I am using ASP.NET 2.0 and Third party Infragistic Controls. I Have included master page in my page (<%@ Page Language="VB"...
2
5521
by: =?Utf-8?B?REo=?= | last post by:
I have a peculiar problem here that I did not have until I migrated from ASP.NET 2.0 to 3.5. I use a master page for my application. Because the master page uses update panels I have the...
2
2687
by: Jay | last post by:
I have a web app running on the windows CE device. In one of the asp.net pages - it has javascript code. That seems to have a memory leak. When I run the web app - in about one hour, the app hangs....
0
7136
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
7412
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...
1
7069
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...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3216
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.