Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Simple Javascript in ASP.NET

Reply
Thread Tools

Simple Javascript in ASP.NET

 
 
Brian Piotrowski
Guest
Posts: n/a
 
      09-14-2006
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.


 
Reply With Quote
 
 
 
 
Mike Lowery
Guest
Posts: n/a
 
      09-14-2006
Have you tried:

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

"Brian Piotrowski" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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.
>



 
Reply With Quote
 
 
 
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      09-14-2006
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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.
>



 
Reply With Quote
 
bruce barker \(sqlwork.com\)
Guest
Posts: n/a
 
      09-14-2006
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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.
>



 
Reply With Quote
 
Laurent Bugnion
Guest
Posts: n/a
 
      09-15-2006
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="..."></script> form.

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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple VB.Net / webservice requirement (but not simple for me....) Dave E ASP .Net 7 01-11-2006 02:07 PM
Simple Question - Simple Answer? Daniel Frey XML 4 01-12-2005 04:25 PM
Re: Simple Simple question!!! Kevin Spencer ASP .Net 0 06-25-2004 05:25 PM
Re: Simple Simple question!!! ashelley@inlandkwpp.com ASP .Net 0 06-25-2004 04:18 PM
A few simple problems in a simple program. jmac@berkeley.edu C Programming 7 07-23-2003 09:51 PM



Advertisments