<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Controls collection cannot be modified Archives : Binary Bits</title>
	<atom:link href="https://blog.binarybits.net/tag/controls-collection-cannot-be-modified/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.binarybits.net/tag/controls-collection-cannot-be-modified/</link>
	<description>Bits &#38; Pieces - A blog by Kannan Balasubramanian</description>
	<lastBuildDate>Mon, 13 Feb 2012 12:24:45 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>The Controls collection cannot be modified because the control contains code blocks (i.e. ).</title>
		<link>https://blog.binarybits.net/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks-i-e/</link>
					<comments>https://blog.binarybits.net/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks-i-e/#respond</comments>
		
		<dc:creator><![CDATA[Kannan]]></dc:creator>
		<pubDate>Mon, 13 Feb 2012 12:24:45 +0000</pubDate>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Controls collection cannot be modified]]></category>
		<category><![CDATA[Error]]></category>
		<category><![CDATA[SharePoint]]></category>
		<guid isPermaLink="false">https://blog.binarybits.net/?p=211</guid>

					<description><![CDATA[<p>While I was writing an in-line code with javascript inside the master page I was constantly facing the following exception. The Controls collection cannot be modified because the control contains code blocks (i.e. &#60;% … %&#62;). Welcome, &#60;script type=”text/javascript”&#62;var loginName = “&#60;%= SPContext.Current.Web.CurrentUser.Name %&#62;”;document.write(loginName);&#60;/script&#62; Found out that the javascript with c# code needs to be out of [&#8230;]</p>
<p>The post <a href="https://blog.binarybits.net/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks-i-e/">The Controls collection cannot be modified because the control contains code blocks (i.e. ).</a> appeared first on <a href="https://blog.binarybits.net">Binary Bits</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>While I was writing an in-line code with javascript inside the master page I was constantly facing the following exception.</p>
<blockquote><p>The Controls collection cannot be modified because the control contains code blocks (i.e. &lt;% … %&gt;).</p>
<p>Welcome, &lt;script type=”text/javascript”&gt;var loginName = “&lt;%= SPContext.Current.Web.CurrentUser.Name %&gt;”;document.write(loginName);&lt;/script&gt;</p></blockquote>
<p>Found out that the javascript with c# code needs to be out of the tag which has runat=&#8221;server&#8221;. After checking the code I re-wrote the code into 2 pieces</p>
<blockquote><p>&lt;script type=&#8221;text/javascript&#8221;&gt;var loginName = &#8220;&lt;%= Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.Name %&gt;&#8221;;&lt;/script&gt;</p></blockquote>
<p>The above code I moved out of the &#8220;&lt;form runat=&#8221;server&#8221;&#8230;&#8221; code and the below code inside the required location.</p>
<blockquote><p>&lt;span&gt;Welcome, &lt;script type=&#8221;text/javascript&#8221;&gt;document.write(loginName);&lt;/script&gt;&lt;/span&gt;</p></blockquote>
<p>Now the page is rendered properly.</p>
<p>&nbsp;</p>
<p>The post <a href="https://blog.binarybits.net/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks-i-e/">The Controls collection cannot be modified because the control contains code blocks (i.e. ).</a> appeared first on <a href="https://blog.binarybits.net">Binary Bits</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.binarybits.net/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks-i-e/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: blog.binarybits.net @ 2026-04-23 06:42:42 by W3 Total Cache
-->