Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Using .js files rather than embedded js

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lloyd Sheen - 10 Dec 2007 15:13 GMT
I am trying to migrate from lots of javascript embedded within an aspx file
to using .js files.

So far no luck.  I have created the .js file which contains part of the
javascript which was part of the aspx file and worked correctly.

First it seems that I cannot get what should exist in the .js file.  I
assume although finding real examples on the net is more difficult than I
thought.  My .js file contains 3 functions.  There is no script tag.

I then (although I have tried the RegisterClientScriptBlock method) to
simply put the following into the <head

<script src="ZipFileHandling.js" type="text/javascript"
language="javascript"></script>

Now when I run I get that wonderful "A Runtime Error has occured. Do you
wish to debug?  Line 3 Error Syntax error".  Of course what is line 3????

Right now I am stuck.

Thanks
Lloyd Sheen
Larry Bud - 10 Dec 2007 15:31 GMT
> I am trying to migrate from lots of javascript embedded within an aspx file
> to using .js files.
[quoted text clipped - 16 lines]
>
> Right now I am stuck.

Line 3 is probably in your .js file.  Sounds like a syntax error to
me.  Perhaps you're missing a paren.  Can you post some of your .js
file?
Peter Bromberg [C# MVP] - 10 Dec 2007 15:36 GMT
Line 3 - sounds to me like whatever was on Line 3 of your script.js file. Did
you remote the "<script>" tags from the file? If it's an include from a src=
attribute, you don't want them in the actual file.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com 

> I am trying to migrate from lots of javascript embedded within an aspx file
> to using .js files.
[quoted text clipped - 19 lines]
> Thanks
> Lloyd Sheen
Lloyd Sheen - 10 Dec 2007 15:44 GMT
> Line 3 - sounds to me like whatever was on Line 3 of your script.js file.
> Did
[quoted text clipped - 30 lines]
>> Thanks
>> Lloyd Sheen

I had 3 functions in one .js file.  When I took 2 of them out and put them
back into the aspx file I had no problem.

Is there a way to put more than one function into a .js file.  I am doing
this (one to learn) and mostly to make the aspx file more readable.

Thanks
Lloyd Sheen
Mark Rae [MVP] - 10 Dec 2007 16:20 GMT
> I had 3 functions in one .js file.  When I took 2 of them out and put them
> back into the aspx file I had no problem.
>
> Is there a way to put more than one function into a .js file.  I am doing
> this (one to learn) and mostly to make the aspx file more readable.

You can have as many as you like...

Just make sure that each is correctly parenthesised e.g.

function firstFunction()
{

}

function secondFunction()
{

}

And remember not to include any <script> tags...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Lloyd Sheen - 10 Dec 2007 16:46 GMT
>> I had 3 functions in one .js file.  When I took 2 of them out and put
>> them back into the aspx file I had no problem.
[quoted text clipped - 17 lines]
>
> And remember not to include any <script> tags...

Thanks Marc,

It was an script tag in the file.  I will attribute this to monday morning.

This make my aspx file much easier to deal with and the javascript most of
which works fine be isolated so that I can find the areas that need changes
much faster.

Lloyd Sheen
Mark Rae [MVP] - 10 Dec 2007 16:58 GMT
> Thanks Marc,

You're welcome Lloyt.

> It was an script tag in the file.

I had a feeling it might be... :-)

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.