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)