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 / October 2007

Tip: Looking for answers? Try searching our database.

Reading JavaScript File Issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
stephen - 03 Oct 2007 17:39 GMT
Hi,

I have a javascript file that I want to use on a button.

If I have the javascript file in the same folder as the webform then it
works for eg:
/SampleApp/WebForms/TestForm.aspx

but I want to try to read the javascript from another folder for e.g
/SampleApp/JScript/MyJavaScript.js

Here is my code:
if (!Page.IsClientScriptBlockRegistered("TestJavaScript"))
{
   Page.RegisterClientScriptBlock("TestJavaScript", "<script
Language='JavaScript' src='MyJavaScriptFile.js'></script>");

   "I want to change it to ---- src='~/JScript/MyJavaScriptFile.js'
}

btnRegisterClientScriptBlockJS.Attributes.Add("onclick",
"ConfirmationWindow();");

It does not work if i change it to second option...
any advice.
Thanks,
Stephen
Alexey Smirnov - 03 Oct 2007 17:55 GMT
> Hi,
>
[quoted text clipped - 24 lines]
> Thanks,
> Stephen

~ cannot be executed outside the ASP.NET

use src='/JScript/MyJavaScriptFile.js' or '../JScript/
MyJavaScriptFile.js'
stephen - 03 Oct 2007 18:16 GMT
Thanks Alexey,

the second option you suggested worked.

stephen

>> Hi,
>>
[quoted text clipped - 29 lines]
> use src='/JScript/MyJavaScriptFile.js' or '../JScript/
> MyJavaScriptFile.js'
Alexey Smirnov - 03 Oct 2007 18:43 GMT
> Thanks Alexey,
>
[quoted text clipped - 35 lines]
> > use src='/JScript/MyJavaScriptFile.js' or '../JScript/
> > MyJavaScriptFile.js'

okay, it means that SampleApp is not a root directory, so the absolute
path  must be src='/SampleApp/JScript/MyJavaScriptFile.js'

".." means parent directory (one level up in a relative path)

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.