473,804 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading JavaScript File Issue

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.IsClient ScriptBlockRegi stered("TestJav aScript"))
{
Page.RegisterCl ientScriptBlock ("TestJavaScrip t", "<script
Language='JavaS cript' src='MyJavaScri ptFile.js'></script>");

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

btnRegisterClie ntScriptBlockJS .Attributes.Add ("onclick",
"ConfirmationWi ndow();");
It does not work if i change it to second option...
any advice.
Thanks,
Stephen
Oct 3 '07 #1
3 1315
On Oct 3, 6:39 pm, "stephen" <stephen...@hot mail.comwrote:
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.IsClient ScriptBlockRegi stered("TestJav aScript"))
{
Page.RegisterCl ientScriptBlock ("TestJavaScrip t", "<script
Language='JavaS cript' src='MyJavaScri ptFile.js'></script>");

"I want to change it to ---- src='~/JScript/MyJavaScriptFil e.js'

}

btnRegisterClie ntScriptBlockJS .Attributes.Add ("onclick",
"ConfirmationWi ndow();");

It does not work if i change it to second option...
any advice.
Thanks,
Stephen
~ cannot be executed outside the ASP.NET

use src='/JScript/MyJavaScriptFil e.js' or '../JScript/
MyJavaScriptFil e.js'

Oct 3 '07 #2
Thanks Alexey,

the second option you suggested worked.

stephen

"Alexey Smirnov" <al************ @gmail.comwrote in message
news:11******** ************@y4 2g2000hsy.googl egroups.com...
On Oct 3, 6:39 pm, "stephen" <stephen...@hot mail.comwrote:
>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.IsClient ScriptBlockRegi stered("TestJav aScript"))
{
Page.RegisterCl ientScriptBlock ("TestJavaScrip t", "<script
Language='Java Script' src='MyJavaScri ptFile.js'></script>");

"I want to change it to ---- src='~/JScript/MyJavaScriptFil e.js'

}

btnRegisterCli entScriptBlockJ S.Attributes.Ad d("onclick",
"ConfirmationW indow();");

It does not work if i change it to second option...
any advice.
Thanks,
Stephen

~ cannot be executed outside the ASP.NET

use src='/JScript/MyJavaScriptFil e.js' or '../JScript/
MyJavaScriptFil e.js'

Oct 3 '07 #3
On Oct 3, 7:16 pm, "stephen" <stephen...@hot mail.comwrote:
Thanks Alexey,

the second option you suggested worked.

stephen

"Alexey Smirnov" <alexey.smir... @gmail.comwrote in message

news:11******** ************@y4 2g2000hsy.googl egroups.com...O n Oct 3, 6:39 pm, "stephen" <stephen...@hot mail.comwrote:
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.IsClient ScriptBlockRegi stered("TestJav aScript"))
{
Page.RegisterCl ientScriptBlock ("TestJavaScrip t", "<script
Language='JavaS cript' src='MyJavaScri ptFile.js'></script>");
"I want to change it to ---- src='~/JScript/MyJavaScriptFil e.js'
}
btnRegisterClie ntScriptBlockJS .Attributes.Add ("onclick",
"ConfirmationWi ndow();");
It does not work if i change it to second option...
any advice.
Thanks,
Stephen
~ cannot be executed outside the ASP.NET
use src='/JScript/MyJavaScriptFil e.js' or '../JScript/
MyJavaScriptFil e.js'
okay, it means that SampleApp is not a root directory, so the absolute
path must be src='/SampleApp/JScript/MyJavaScriptFil e.js'

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

Oct 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
20548
by: Eddie | last post by:
When I use JavaScript to read an element's textDecoration style, I only get one value even if there are more than one in the sytle sheet. For example if the text-decoration is defined as: text-decoration : underline overline; when reading element.currentStyle.textDecoration I only get "underline"!! What's worse is that element.style.textDecorationUnderline returns
53
5757
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
2
10703
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It appears to be in the OLEDB driver also. My connection was: conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";" & "Extended Properties='Text;HDR=NO;FMT=Delimited'"
2
3036
by: Steve | last post by:
OK, I know I can't read a file with JavaScript, but I see references that I can use the filesystemobject which is part of vb script. Can I embed vb script in HTML? I am writing a program for company internal use that will extract information from a drawing on the user's local workstation and then needs to convey that information to a web app communicating to the user through their brower. Everything is pretty much microsoft tho' we...
21
18257
by: ryanmhuc | last post by:
I know the subject might be confusing. I am no beginner with javascript but I haven't been able to figure out how to get the javascript file name from code inside the file. So you have an HTML doc with script tag who's source is a javascript file. <HTML> <script src="javascript.js"></script> </HTML> Javascript.js
7
6069
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should populate a series of structures of specified variable composition. I have the structures created OK, but actually reading the files is giving me an error. Can I ask a simple question to start with: I'm trying to read the file using the...
2
1629
by: RR | last post by:
I'm trying to read an xml file into a dataset just like I do in my windows application. DataSet.ReadXML("filename.xml"); But no matter how I have the string file name the application errors and I get File Not Found when I debug on the emulator. Since I'm fairly new to mobile development, do I need to do anything in particular to load the xml file to the emulator / device? The xml file is in the project folder.
3
1612
by: John | last post by:
How can I tell if a line begins with a number instead of a character? I need to read a text file and some of the data begins with a character which is causing me an issue in reading and uploading my file. I only need the data if it begins with a number (numeric) value.
3
2962
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, This is an issue that happens to me and everybody else I know and I've never found a way around it. In Visual Studio (currently using 2003 but the same has happened for me in 2005 and 2008 as well) If I put a breakpoint in a .js file, the debugger picks it up and breaks into it at that point.
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10096
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.