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 / March 2008

Tip: Looking for answers? Try searching our database.

Javastript file still won't work...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matthew Wells - 02 Mar 2008 17:51 GMT
Hello.  This is a repost because nothing has worked so far.

I thought this was supposed to be simple.  I'm trying to use a .js file for
my javascript functions.  I'm testing by only using one function   The
function works when it's at the top of my aspx file.

The file is called "MyFunctions.js" which was imported on the page load
event of the code-behind form with:
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyFuncs",
"MyFunctions.js", true); - I've used this with both true and false and with
adding script tags myself in the .js file.

I've also tried
Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "MyFuncs",
"MyFunctions.js");

The .js file is in the same directory as the page. and has only one
function:

function SayHello()
{
   alert("Hello");
}

I added the function call on the code behind page load

btnLast.Attributes.Add("onclick", "SayHello()");

is there supposed to be some directive in the .js file?

I've also tried just directly referencing the file in the aspx file with:
<script type="text/javascript" src="MyFunctions.js"></script>
Still no luck.

Any ideas?  This is STILL driving me nuts!!!

Thanks.

Matthew Wells
Matthew.Wells@FirstByte.net
Michael Nemtsev [MVP] - 03 Mar 2008 00:14 GMT
Hello Matthew,

Have u tried to use ClientScriptManager.RegisterStartupScript ?

---
WBR,
Michael  Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour 

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

MW> Hello.  This is a repost because nothing has worked so far.
MW>
MW> I thought this was supposed to be simple.  I'm trying to use a .js
MW> file for my javascript functions.  I'm testing by only using one
MW> function   The function works when it's at the top of my aspx file.
MW>
MW> The file is called "MyFunctions.js" which was imported on the page
MW> load event of the code-behind form with:
MW> Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
MW> "MyFuncs", "MyFunctions.js", true); - I've used this with both true
MW> and false and with adding script tags myself in the .js file.
MW>
MW> I've also tried
MW> Page.ClientScript.RegisterClientScriptInclude(this.GetType(),
MW> "MyFuncs", "MyFunctions.js");
MW>
MW> The .js file is in the same directory as the page. and has only one
MW> function:
MW>
MW> function SayHello()
MW> {
MW> alert("Hello");
MW> }
MW> I added the function call on the code behind page load
MW>
MW> btnLast.Attributes.Add("onclick", "SayHello()");
MW>
MW> is there supposed to be some directive in the .js file?
MW>
MW> I've also tried just directly referencing the file in the aspx file
MW> with:
MW> <script type="text/javascript" src="MyFunctions.js"></script>
MW> Still no luck.
MW> Any ideas?  This is STILL driving me nuts!!!
MW>
MW> Thanks.
MW>
MW> Matthew Wells
MW> Matthew.Wells@FirstByte.net
Matthew Wells - 06 Mar 2008 13:08 GMT
I'm trying it, but I can't seem to get the syntax down.  Can you show me an
example?

Thanks.

Matthew Wells
Matthew.Wells@FirstByte.net
> Hello Matthew,
>
[quoted text clipped - 37 lines]
> MW> MW> Matthew Wells
> MW> Matthew.Wells@FirstByte.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.