Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 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 Professional 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 October 22nd, 2007, 07:45 AM
Authorized User
 
Join Date: Sep 2006
Posts: 37
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to VerbatimBOT Send a message via Yahoo to VerbatimBOT
Default The Controls collection cannot be modified...

Hi all!
I'm having troubles with dynamically adding some attributes to IMG tag within the asp:Panel.

Here is the code:
Code:
<asp:Panel ID="panelArea" runat="server">
  <table border="0" width="100%">
    <tr>
      <td>
        <asp:PlaceHolder ID="phArea" runat="server" />
      </td>
      <td>
        <img id='<%= "tabImg" + ClientID %>' src='<%= ImageUrlOpen %>' />
      </td>
    </tr>
  </table>
</asp:Panel>
The error I keep getting is The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Has anyone faced this problem earlier?
Thanks!

Aleksandar Dragosavac
Belgrade, Serbia
__________________
Aleksandar Dragosavac
Belgrade, Serbia
 
Old October 22nd, 2007, 09:18 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Don't use the ASP style <% %> code block. I see any reason you need these. Instead, you should use an ASP:IMAGE control.

What control are you trying to add the controls to? You state "within the asp:Panel" however, it looks from your code that you should be adding them to the "phArea" placeholder instead.

-Peter
 
Old October 22nd, 2007, 09:43 AM
Authorized User
 
Join Date: Sep 2006
Posts: 37
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to VerbatimBOT Send a message via Yahoo to VerbatimBOT
Default

You're right!
I have replaced
Code:
<img id='<%= "tabImg" + ClientID %>' src='<%= ImageUrlOpen %>' />
with
Code:
<asp:Image ID="tabImg" runat="server" ImageUrl='<%# ImageUrlOpen %>' />
and it gives me no error. I don't know why was I insisted on html IMG tag instead of using asp:Image...

Yes, I will be adding dynamically controls to phArea (have a couple of methods for that).

Thanks a lot!

Aleksandar Dragosavac
Belgrade, Serbia





Similar Threads
Thread Thread Starter Forum Replies Last Post
cms: Last modified.... retroviz BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 February 24th, 2007 06:01 AM
System.Web.UI.Control.Controls Collection Ihoulun ASP.NET 1.0 and 1.1 Basics 0 October 17th, 2006 07:51 AM
last modified date on folders holdmykidney J2EE 0 May 23rd, 2005 07:47 AM
urgent custom control with collection of controls dd_smith Pro VB.NET 2002/2003 1 December 19th, 2004 06:05 PM
Collection of Controls? Nick.Net VB.NET 2002/2003 Basics 2 November 5th, 2003 04:18 PM





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