Free Download:
|
| |
| BrockAllen | Asp.Net User |
| Re: Javascript and Master Page problem | 7/23/2005 3:43:57 PM |
0/0 | |
|
Yes, external file references from the matser are relative to the page that's being executed, not the master. So, in the master make your control runat=server and use the ~/path to reference the external file. The ~ syntax doesn't work unless the tag/control is a server side control. -Brock DevelopMentorhttp://staff.develop.com/ballen |
| Shuf | Asp.Net User |
| Re: Javascript and Master Page problem | 7/23/2005 7:01:37 PM |
0/0 | |
|
yes, i know about that already because i'm using ~ for images, and they
load fine. Here's the code snippet from my work. If i'm using .., pages
which are in the same level as master pages loads fine. but if i change
it to ~, it doesnt load at all. it doesnt make much sense, because for
css file, i just use .., and the pages are ok regardless of the
hierarchy level. but for javascript, it's not the case. it will report
an error; Object expected.
<head runat="server">
<title>Example Site</title>
<link href="../Styles/Style.css" rel="stylesheet" type="text/css" />
<link href="../Styles/NiftyCorners.css" rel="stylesheet" type="text/css" />
<script src="../Scripts/Nifty.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload=function(){
if(!NiftyCheck())
return;
Rounded("div#doc_brc","all","transparent","#ffffff","border #cccccc");
Rounded("div#searchBox_brc","all","#ffffff","#ffffff","border #cccccc");
Rounded("div.header_brc","all","#ffffff","#f0f0f0","smooth");
}
</script>
</head>
here's some of the variation i've tried, and obviously not working.
<link href="../Scripts/Nifty.js" type="text/javascript"/>
<link href="../Scripts/Nifty.js" type="text/javascript" runat="server"/>
<link href="~/Scripts/Nifty.js" type="text/javascript"/>
<link href="~/Scripts/Nifty.js" type="text/javascript"/ runat="server">
<script src="../Scripts/Nifty.js" type="text/javascript"></script>
<script src="~/Scripts/Nifty.js" type="text/javascript" runat="server"></script>
if you need more than just the code i pasted above, please tell me and i'll email it to you
|
| BrockAllen | Asp.Net User |
| Re: Javascript and Master Page problem | 7/23/2005 9:14:44 PM |
0/0 | |
|
<link rel=stylesheet type=text/css runat=server src="~/path/file.css" /> will work fine for CSS files. For .js files you'll need to instead call: Page.ClientScript.RegisterClientScriptInclude("MyKey", "~/path/file.js"); And you can do this from your master in the Page_Load event. -Brock DevelopMentorhttp://staff.develop.com/ballen |
| BrockAllen | Asp.Net User |
| Re: Javascript and Master Page problem | 7/24/2005 3:59:32 PM |
0/0 | |
|
Gah, sorry I'm being so sloppy. Take the "~/path/file.js" and wrap it with a call to ResolveClientUrl. -Brock DevelopMentorhttp://staff.develop.com/ballen |
| BrockAllen | Asp.Net User |
| Re: Javascript and Master Page problem | 7/25/2005 2:19:08 PM |
0/0 | |
| |
| WorkingMan2005 | Asp.Net User |
| Re: Javascript and Master Page problem | 1/9/2006 7:56:50 PM |
0/0 | |
|
I hope I came across this post last week.
Here is what I used for a content page to use Javascript and that is also linked to a MasterPage.
// Define the name, type and url of the client script on the page.
String csname = "UtilScript";
String csurl = this.ResolveClientUrl("~/script/util.js"); //thanks to this post I update this with ResolveClientUrl
Type cstype = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the include script exists already.
if (!cs.IsClientScriptIncludeRegistered(cstype, csname))
{
cs.RegisterClientScriptInclude(cstype, csname, csurl);
}
The source code generated at runtime give you something like that (path will differ for different environment)
<script src="../script/util.js" type="text/javascript"></script>
Including the above line in your content file directly will not work (as I tried it) for whatever reason (maybe someone can provide a reason/solution). Including a .js is the easiest and safest way to include javascript content. This is the guaranteed way to successfully access javascript (otherwise you might get : object expected error) on the content page. |
|
| |
Free Download:
|
Books: Beginning ASP.NET 3.5: In C# and VB Authors: Imar Spaanjaars, Pages: 734, Published: 2008 ASP.NET 2.0 MVP Hacks and Tips Authors: David Yack, Joe Mayo, Scott Hanselman, Fredrik Normén, Dan Wahlin, J. Ambrose Little, Jonathan Goodyear, Pages: 400, Published: 2006 Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005 Microsoft Office SharePoint Server 2007: The Complete Reference Authors: David Matthew Sterling, David Sterling, Pages: 788, Published: 2007 Professional ASP.NET 3.5: In C# and VB Authors: Bill Evjen, Scott Hanselman, Devin Rader, Pages: 1673, Published: 2008 Amazon.com Mashups Authors: Francis Shanahan, Pages: 379, Published: 2006 Brilliant Microsoft Expression Web Authors: Steve Johnson, Pages: 366, Published: 2007 Pro ASP.NET 2.0 Website Programming Authors: Damon Armstrong, Pages: 641, Published: 2005 ASP.NET 2.0: A Developer's Notebook Authors: Wei Meng Lee, Pages: 326, Published: 2005 Microsoft Expression Web 2007 in Depth Authors: Jim Cheshire, Pages: 792, Published: 2008 Web:ASP.NET 2.0 Master Page Problem However, I have not found a fix for the javascript! .... NET 2.0 master pages. Message: I was working on a problem with your menu when ... JavaScript problem used in Master Pages and Subfolders the project clean but not able to do this until I fix the problem with JavaScript. I'm using a Master page in the project. Any suggestions? ... Re: [AspNet2] using javascript in master page & content pages ... Sep 12, 2006 ... i have a master page in the main directory and content pages in a > folder...... .i have tried to put the javascript functions on the ... Master Page Error from Exporting file from SharePoint Designer If you are using SharePoint Designer (SPD) to create a master page file that ... Adding Javascript file link in Master Page re: Adding Javascript file link in Master Page. Just had the same problem myself . Although your solution works I would prefer my script to be included in ... MSDN how to call a javascript function from content page which was ... you can call the javascript within the page_prerender()...... event of your Masterpage. I had overcome with the same problem adding the Calendar to a ... problem with javascript and master pages : clientscriptinclude, master Hi I have some code like this in my javascript document.getElementById('<%= Label1.ClientID%>').style.backgroundColor = 'red'; This works ... Scriptmager Bug : Forms Authentication + MasterPage = Javascript ... I'm getting this annoying javascript error from the script manager ('syntax error on line 3') when I have a script manager on a master page ... Problem with java script in master page - ITtoolbox Groups Problem with java script in master page. Your Full Name:. Your Email Address:. Recipient Email(s): Separate multiple addresses with commas. ... Referencing JavaScript in ASP.NET MVC Master Pages Here's a quick tip on including JavaScript files in your MVC master page views. ... But wait! there's a problem with this. Depending on what route has led ... Videos: Gaia Gold Getter! Okay this is a program I found on the Underground section of a cheat site. I am sharing it with you guys. =] Alright, so what you do, after you ... |
|
Search This Site:
|
|