• Toll-free  888-665-8637
  • International  +1 717-220-0012
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Cliff
#1 Posted : Thursday, April 19, 2007 8:48:50 AM(UTC)
Cliff

Rank: Member

Joined: 5/24/2004(UTC)
Posts: 4,147

I'm getting the attached error on My Account and Cart pages after running the updater:

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


What did I do this time? ;)
File Attachment(s):
MyAccount_Orders.aspx.htm (6kb) downloaded 2 time(s).

You cannot view/download attachments. Try to login or register.
jetheredge
#2 Posted : Thursday, April 19, 2007 11:49:31 AM(UTC)
jetheredge

Rank: Member

Joined: 3/1/2006(UTC)
Posts: 1,142

Have you added code blocks into the .aspx page itself?
Justin Etheredge
Senior Software Engineer
BVSoftware
Cliff
#3 Posted : Thursday, April 19, 2007 11:49:37 AM(UTC)
Cliff

Rank: Member

Joined: 5/24/2004(UTC)
Posts: 4,147

Looks like this error goes away when I remove my javascript link in the header of the master page:

Code:
<script type="text/javascript" src="<%= ResolveClientUrl("scripts/sifr.js") %>"></script>


Why would this work on the rest of the master pages, but not MyAccount.master and Cart.master? Because of Utilities.WebForms.MakePageNonCacheable(Me)?
Cliff
#4 Posted : Thursday, April 19, 2007 12:02:06 PM(UTC)
Cliff

Rank: Member

Joined: 5/24/2004(UTC)
Posts: 4,147

Originally Posted by: "Justin Etheredge" Go to Quoted Post
Have you added code blocks into the .aspx page itself?


No, haven't touched MyAccount_Orders.aspx.
bvuser
#5 Posted : Thursday, April 19, 2007 12:02:13 PM(UTC)
bvuser

Rank: Member

Joined: 4/10/2006(UTC)
Posts: 462

Change your script "injector" to use a databinding expression instead

IE, use <%# rather than <%=
Netriplex Corporation<br />
bvuser
#6 Posted : Thursday, April 19, 2007 12:12:18 PM(UTC)
bvuser

Rank: Member

Joined: 4/10/2006(UTC)
Posts: 462

Another thing that may be causing the problem is the double use of double quotes.

Change:

<script type="text/javascript" src="<%= ResolveClientUrl("scripts/sifr.js") %>">

To:

<script type="text/javascript" src='<%= ResolveClientUrl("scripts/sifr.js") %>'>

If this works, it will probably be better performance wise despite the fact no one will porbably know the difference.
Netriplex Corporation<br />
jetheredge
#7 Posted : Thursday, April 19, 2007 12:14:38 PM(UTC)
jetheredge

Rank: Member

Joined: 3/1/2006(UTC)
Posts: 1,142

The issue is that we are programmatically modifying the header block and you can't have code blocks in a control that has had its controls collection modified. The databinding tip that bvuser suggested should work since databinding expressions are resolved at runtime.
Justin Etheredge
Senior Software Engineer
BVSoftware
Cliff
#8 Posted : Thursday, April 19, 2007 12:17:15 PM(UTC)
Cliff

Rank: Member

Joined: 5/24/2004(UTC)
Posts: 4,147

Originally Posted by: "bvuser" Go to Quoted Post
use <%# rather than <%=


That did the trick, thanks! :)
Cliff
#9 Posted : Thursday, April 19, 2007 12:42:24 PM(UTC)
Cliff

Rank: Member

Joined: 5/24/2004(UTC)
Posts: 4,147

Scratch that, it's coming out without the source:

Code:
<script type="text/javascript" src=""></script>


Same error when using single quotes instead of double.

Is there another way to link up a script in the head?
Andy Miller
#10 Posted : Thursday, April 19, 2007 2:23:15 PM(UTC)
Andy Miller

Rank: Member

Joined: 11/5/2003(UTC)
Posts: 2,136

Was thanked: 1 time(s) in 1 post(s)
Try forcing the page to DataBind. For example in the Page_Load method of MyAccount_Orders.aspx.vb




Code:

If Not Page.IsPostBack Then
Me.DataBind()
Page.Title = Content.SiteTerms.GetTerm("OrderHistory")
Me.TitleLabel.Text = Content.SiteTerms.GetTerm("OrderHistory")
LoadOrders()
End If

Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing
bvuser
#11 Posted : Thursday, April 19, 2007 2:23:21 PM(UTC)
bvuser

Rank: Member

Joined: 4/10/2006(UTC)
Posts: 462

Yeah, after justin clarified that he is modifying the HtmlHead dynamically, I knew the second solution would not work.

You are getting an empty result because when using a Databinding expression, you must invoke a Databind call in Code Behind or else you will get nothing.

Sorry, I should have been complete with my instructions.

In the load event of the Codebehind call Page.Header.DataBind()
Netriplex Corporation<br />
Cliff
#12 Posted : Thursday, April 19, 2007 6:00:57 PM(UTC)
Cliff

Rank: Member

Joined: 5/24/2004(UTC)
Posts: 4,147

Oh, good, that works in the codebehind for the master page. I really didn't want to touch anything outside the theme.

Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Page.Header.DataBind()
End Sub


Thanks!

Any downsides to this? Any better way than this to include a script source in the header without using an absolute path?
bvuser
#13 Posted : Friday, April 20, 2007 8:17:53 AM(UTC)
bvuser

Rank: Member

Joined: 4/10/2006(UTC)
Posts: 462

Other Ways, Yes.

Better Ways? Only one that i can think of that may be close to the overhead generated by the databind. I think (spectulating here as I haven't tried it), you can make the head tag a server control by adding runat="server" and then you'd be able to use your standard code block. However, assuming that worked, I think the creation of the head tag as a server control would add more overhead than the databind though.
Netriplex Corporation<br />
Andy Miller
#14 Posted : Friday, April 20, 2007 8:17:57 AM(UTC)
Andy Miller

Rank: Member

Joined: 11/5/2003(UTC)
Posts: 2,136

Was thanked: 1 time(s) in 1 post(s)
I don't know of any downsides. There are other ways to do it, but I think this way has the advantage of being self-documenting. That is, I think you will immediately know what is happening even if you don't look at it for a year.
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing
Cliff
#15 Posted : Saturday, April 21, 2007 9:30:47 AM(UTC)
Cliff

Rank: Member

Joined: 5/24/2004(UTC)
Posts: 4,147

Thanks for the help guys.
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

©2025 Develisys. All rights reserved.
  • Toll-free  888-665-8637
  • International  +1 717-220-0012