external js file with masterpage

S

Stan SR

Hi,

I use a masterpage for all my project.
For some pages I have some external javascript file that I would like to
include.
How can I do this action from the content pages ?

Stan
 
C

Cowboy \(Gregory A. Beamer\)

From individual pages, this is simple. Just link to the JavaScript. From the
master page, it is more difficult, as the JavaScript linking does not
respect the ResolveClientUrl() for some reason. Either that, or I have not
found the magic.

Put the links in teh pages you need, or create a page object that has the
link and inherit from it.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think Outside the Box!
*************************************************
 
P

Pavel Prchal

Stan SR napsal(a):
Hi,

I use a masterpage for all my project.
For some pages I have some external javascript file that I would like to
include.
How can I do this action from the content pages ?

Stan
Try following code(in masterpage's OnLoad)

protected string m_sScript = "MasterPageRoot/MasterPageScript.js";

.....
string sPrefix = string.Empty;
if (Request.AppRelativeCurrentExecutionFilePath.IndexOf("inner-folder")
sPrefix = "../";

this.DataBind();

.... and in masterpage
<script src="<%#m_sScript%>" type="text/javascript">

Pavel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top