Re: Specifying javascript file path on Master pages

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



There is just one like of code... ShowAlert() function in the following code
is defined in my MyDOM.js file. And if you look at the loaded documents
(pages, js etc.) in browser, MyDOM.js is not there. And the call to
ShowAlert ends us generting a JS error.

<head runat=server>
<link href="~/Scripts/MyDOM.js" />
</head>

<body>
<script language=javascript>
ShowAlert();
</script>
</body>

"Ken Cox - Microsoft MVP" <BANSPAMkjopc@xxxxxxxxxxx> wrote in message
news:%23SFQs4nKGHA.648@xxxxxxxxxxxxxxxxxxxxxxx
Show us the code that doesn't work?

"Naveen K Kohli" <naveenkohli@xxxxxxxxxxx> wrote in message
news:Og$LT0nKGHA.1032@xxxxxxxxxxxxxxxxxxxxxxx
Already tried that approach. It does not work at all.

"Ken Cox - Microsoft MVP" <BANSPAMkjopc@xxxxxxxxxxx> wrote in message
news:%23o29ONiKGHA.500@xxxxxxxxxxxxxxxxxxxxxxx
Hi Naveen,

The tilde character (~) stands for the site's root when ASP.NET
interprets it. Therefore, you can create a link to your JavaScript that
runs on the server. I

<link runat="server" href="~/scripts/myfile.js" />

With that, every file should find it.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]


"Naveen K Kohli" <naveenkohli@xxxxxxxxxxx> wrote in message
news:O0g68cgKGHA.2392@xxxxxxxxxxxxxxxxxxxxxxx
I have couple of javascript files that need to be referenced for each
content page. So I am trying to put them on Master page. The problem is
that content pages are not on one level of the site. I have been trying
to find a way to specify path to these JS files so that the actual path
to these files correctly gets applied on the path at every level of the
folder hierarchies. So far no luck...

<script languaage=javascript src="/Scripts/myfile.js" />

Is there any solution to this problem? I have tried to use
Server.MapPath approach to fill src attribute from server side but that
does not fly because it throws exception that controls can't be added
or removed on the page because of theese server tags present on the
page..

Any solution to this problem.. I am this close to abandoning use of
master page concept of asp.net 2

Thanks









.



Relevant Pages

  • Re: Taking over Operations Master / DC roles
    ... > that with the exception of the Single Master Roles." ... my gameplan is to get the server updated and all info copied... ... Get the DNS setup and all my other odds and ends to the point that they are ... >> mapped install directory, and a time server. ...
    (microsoft.public.win2000.active_directory)
  • Re: Get Segmentation Fault when Building Sybase
    ... Doing ldd on the dataserver executable reveals that linux-gate is being used on 32 bit systems for system calls, but not on 64 bit, so any dodgy calls would be handled better on the 64 bit system. ... Building Adaptive Server 'LOCALHOST': ... Building master device... ... No external security mechanisms will be supported. ...
    (comp.databases.sybase)
  • Re: Disaster Recovery Plan
    ... preferable to restoring a master tape, ... Server and a HP tape drive. ... Attend a course taught by an expert instructor with years of in-the-field ...
    (Security-Basics)
  • Re: PCs not seeing each other
    ... MARK-X60S can ping MARK but MARK can not ping MARK-X60S ... Net config server ... Master browser name is: MARK-X60S ... There are 1 servers in domain ANY on transport ...
    (microsoft.public.windowsxp.network_web)
  • Re: Small business thinking about backing up data, having a server and 2-3 users - is SBS200
    ... is networked to the Master with a crossover network cable. ... Master on the Master PC and Client on the Slave pc. ... - Financial Application - Use a server for hosting the financial ...
    (microsoft.public.windows.server.sbs)