470,635 Members | 2,279 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

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

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Astra | last post: by
reply views Thread by 42 | last post: by
73 posts views Thread by Claudio Grondi | last post: by
27 posts views Thread by one man army | last post: by
11 posts views Thread by samuelberthelot | last post: by
24 posts views Thread by firstcustomer | last post: by
4 posts views Thread by Timmah1980 | last post: by
1 post views Thread by www.web20developers.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.