473,406 Members | 2,352 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,406 software developers and data experts.

Simple Javascript in ASP.NET

Hi All,

After many years of ASP 3.0, I am finally taking the plunge and moving to
ASP.NET. I'm going through a few tutorials, and I'm wondering if someone
can answer me a question on adding a simple Javascipt to an ASP.NET page.

In my old ASP code, I used an #include function to add a javascript to my
webpage. I've been reading that it is not recommended to use this technique
in ASP.NET. The javascript I would like to add is pretty basic - it's just
a script to fade between images in the header.

Can someone tell me what I could do as an alternate to the #include function
under ASP.NET? I'd really hate to have to post the javascipt in my master
file if I can avoid it.

So before, I had this:

<head>
<!--#include file ="stylesheet.css"-->
<!--#include file ="fadescript.js"-->
</head>

I figured out how to show the stylesheet in the page. My question is how do
I get the fadescript.js into my ASP.NET pages?

Thanks!

Brian.
Sep 14 '06 #1
4 1524
Have you tried:

<script type="text/javascript" SRC="filename.js" />

"Brian Piotrowski" <bp*********@N0SPAM-simcoeparts.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi All,

After many years of ASP 3.0, I am finally taking the plunge and moving to
ASP.NET. I'm going through a few tutorials, and I'm wondering if someone can
answer me a question on adding a simple Javascipt to an ASP.NET page.

In my old ASP code, I used an #include function to add a javascript to my
webpage. I've been reading that it is not recommended to use this technique
in ASP.NET. The javascript I would like to add is pretty basic - it's just a
script to fade between images in the header.

Can someone tell me what I could do as an alternate to the #include function
under ASP.NET? I'd really hate to have to post the javascipt in my master
file if I can avoid it.

So before, I had this:

<head>
<!--#include file ="stylesheet.css"-->
<!--#include file ="fadescript.js"-->
</head>

I figured out how to show the stylesheet in the page. My question is how do I
get the fadescript.js into my ASP.NET pages?

Thanks!

Brian.

Sep 14 '06 #2
It is a bit different. Theres a really good tutorial here for you courtesy
of Microsoft on how to work with Javascript.
http://msdn.microsoft.com/library/de.../JAVAwASP2.asp

Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
"Brian Piotrowski" <bp*********@N0SPAM-simcoeparts.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi All,

After many years of ASP 3.0, I am finally taking the plunge and moving to
ASP.NET. I'm going through a few tutorials, and I'm wondering if someone
can answer me a question on adding a simple Javascipt to an ASP.NET page.

In my old ASP code, I used an #include function to add a javascript to my
webpage. I've been reading that it is not recommended to use this
technique in ASP.NET. The javascript I would like to add is pretty
basic - it's just a script to fade between images in the header.

Can someone tell me what I could do as an alternate to the #include
function under ASP.NET? I'd really hate to have to post the javascipt in
my master file if I can avoid it.

So before, I had this:

<head>
<!--#include file ="stylesheet.css"-->
<!--#include file ="fadescript.js"-->
</head>

I figured out how to show the stylesheet in the page. My question is how
do I get the fadescript.js into my ASP.NET pages?

Thanks!

Brian.

Sep 14 '06 #3
instead of a server include use a javascript ref:

<head>
<script src="fadescript.js" />
</head>

be sure to remove script tags from the js file

-- bruce (sqlwork.com)
"Brian Piotrowski" <bp*********@N0SPAM-simcoeparts.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi All,

After many years of ASP 3.0, I am finally taking the plunge and moving to
ASP.NET. I'm going through a few tutorials, and I'm wondering if someone
can answer me a question on adding a simple Javascipt to an ASP.NET page.

In my old ASP code, I used an #include function to add a javascript to my
webpage. I've been reading that it is not recommended to use this
technique in ASP.NET. The javascript I would like to add is pretty
basic - it's just a script to fade between images in the header.

Can someone tell me what I could do as an alternate to the #include
function under ASP.NET? I'd really hate to have to post the javascipt in
my master file if I can avoid it.

So before, I had this:

<head>
<!--#include file ="stylesheet.css"-->
<!--#include file ="fadescript.js"-->
</head>

I figured out how to show the stylesheet in the page. My question is how
do I get the fadescript.js into my ASP.NET pages?

Thanks!

Brian.

Sep 14 '06 #4
Hi,

bruce barker (sqlwork.com) wrote:
instead of a server include use a javascript ref:

<head>
<script src="fadescript.js" />
</head>

be sure to remove script tags from the js file

-- bruce (sqlwork.com)
Note that depending on the DOCTYPE, having a script tag without end tag
can cause problems. You should also set the type to avoid errors. I
recommend using the <script type="text/javascript" src="..."></scriptform.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 15 '06 #5

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

Similar topics

6
by: francisco lopez | last post by:
ok , first of all sorry if my english is not so good, I do my best. here is my problem: I don´t know much javascript so I wrote a very simple one to validate a form I have on my webpage. ...
9
by: Astra | last post by:
Hi everybody Wonder if you could help me out. I created a simple JavaScript routine to enable a user to click backwards and forwards between small news articles. This routine works fine in IE...
0
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I...
73
by: Claudio Grondi | last post by:
In the process of learning about some deeper details of Python I am curious if it is possible to write a 'prefix' code assigning to a and b something special, so, that Python gets trapped in an...
27
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res =...
11
by: samuelberthelot | last post by:
Hi, I've got 3 input HTML (dropdown lists) on my page. One for selecting a Month, one for the day, one for the year. Very simple... My problem is that I'd like to update the Days one according...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
4
by: Timmah1980 | last post by:
I'm sure this is a simple enough fix for someone out there, but I'm afraid it's beyond me! I'm putting together this simple menu for a client: http://www.timkeay.co.uk/mpc2/index.htm It...
13
by: aum | last post by:
Hi, I'm a Python programmer, just starting to get into javascript. On reading some of the js guides, and not liking any of the OO usage patterns I saw, I've cooked up something which python...
1
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX -...
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
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
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
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
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,...

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.