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. |
|
|
|
|
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 |
|
|
|
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)? |
|
|
|
|
Rank: Member
Joined: 5/24/2004(UTC) Posts: 4,147
|
Originally Posted by: "Justin Etheredge" Have you added code blocks into the .aspx page itself? No, haven't touched MyAccount_Orders.aspx. |
|
|
|
|
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 /> |
|
|
|
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 /> |
|
|
|
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 |
|
|
|
Rank: Member
Joined: 5/24/2004(UTC) Posts: 4,147
|
Originally Posted by: "bvuser" use <%# rather than <%= That did the trick, thanks! :) |
|
|
|
|
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? |
|
|
|
|
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
|
|
|
|
|
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 /> |
|
|
|
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? |
|
|
|
|
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 /> |
|
|
|
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. |
|
|
|
|
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.