Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2011, 03:00 PM
Registered User
 
Join Date: Feb 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using <asp:Literl> will be better than <%=helper%>...

I too needed to locate the included javascript file at the application root level for my master page. So I put a public variable that contains the HttpContext.Current.Request.ApplicationPath info in the master page's code behind and used it at the front like the code below in the <header runat="server >.

Code:
<script src="<%=AppRoot%>Scripts/Tools.js" type="text/javascript"></script>
It was working just fine until I put an ajax calendar control in one of my page. Suddenly the page failed with the error below:

"The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). "

Once I removed the entire line using the literal tag, it is working again.

Code:
<asp:Literal ID="ltlJavaScriptsFile" runat="server" />
code behind looks like:
Code:
ltlJavaScriptsFile.Text = "<script src=""" & HttpContext.Current.Request.ApplicationPath & "Scripts/Tools.js"" type=""text/javascript""></script>"
So for some reason the ajax controls doesn't like <%= %> in the <head runat="server"> section. This is under .net 4 with ajax tool kit for .net 4.





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make it work? ashokparchuri ADO.NET 2 March 4th, 2005 07:00 AM
Cannot make site work wenlanli BOOK: ASP.NET Website Programming Problem-Design-Solution 1 September 3rd, 2004 11:39 AM
Can't make sample project work sillygiu@hotmail.com All Other Wrox Books 1 August 17th, 2004 03:02 AM
Cannot make my IIS work w_erik BOOK: Beginning ASP.NET 1.0 2 May 11th, 2004 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.