?
Solved

using code block with <%# instead of <%=

Posted on 2014-10-24
4
Medium Priority
?
83 Views
Last Modified: 2014-10-28
Can anyone explain what the difference is between using a code block with  <%#  instead of  <%=   ?

When adding controls dynamically to a page, the later causes:

“The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).”
0
Comment
Question by:HLRosenberger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 40402541
<%= is a shortcut for response.write
<%# is used during databinding.

More info can be found here:
http://forums.asp.net/post/1828702.aspx
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 40402618
Thanks!  that was useful.

I'm using a third party WEB page generator tool.  It create stuff like this:

<%= SystemUtils.GenerateEnterKeyCaptureBeginTag(FindControlRecursively("CancelButton"))%>

The <%= prevents me from adding controls dynamically to a page.  Question:  Does changing <%= to <%# have any impact?  Can <%#  always be used instead of <%=?
0
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 40402653
Basically if the control you are trying to use is not in a databindable container you're going to run into issues.

Also you have to first databind the control before any data will display.

Example:
you put a datagrid on a webform.  The header shows up.  You databind the grid and the rows now show up.

that's using the <%#
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 40409422
thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question