<?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>blog.aaziz.org &#187; asp.net</title>
	<atom:link href="http://blog.aaziz.org/tag/aspnet/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.aaziz.org</link>
	<description>ramblings and opinions of a geek</description>
	<lastBuildDate>Fri, 08 Oct 2010 00:26:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Referencing ASP.NET User Controls in Code-behind</title>
		<link>http://blog.aaziz.org/referencing-aspnet-user-controls-in-code-behind</link>
		<comments>http://blog.aaziz.org/referencing-aspnet-user-controls-in-code-behind#comments</comments>
		<pubDate>Tue, 26 May 2009 20:52:04 +0000</pubDate>
		<dc:creator>Anthony Aziz</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[solution]]></category>

		<guid isPermaLink="false">http://blog.aaziz.org/?p=108</guid>
		<description><![CDATA[I recently had an issue where I converted some User Controls to code-behind model, and moved them to another directory. I then found I couldn&#8217;t reference them in code. After a post on the ASP.NET forums, I came to a solution, and devised the rules as to how you can reference a User Control in [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had an issue where I converted some User Controls to code-behind model, and moved them to another directory. I then found I couldn&#8217;t reference them in code. After a <a title="Using the class of a user control in code-behind" href="http://forums.asp.net/t/1426138.aspx">post on the ASP.NET forums</a>, I came to a solution, and devised the rules as to how you can reference a User Control in code:</p>
<ol>
<li>The control needs to have a ClassName tag in the &lt;%@ Control %&gt; tag (actually, I think if it doesn&#8217;t you&#8217;ll use the generated class name?)</li>
<li>The page has to use a &lt;%@ Reference %&gt; tag in the .aspx file to reference the control</li>
<li>If page uses a code-behind file, the namespace &#8220;ASP&#8221; contains all controls reference with the &lt;%@ Reference %&gt; tag. If it&#8217;s inline code, there&#8217;s no need for this.</li>
</ol>
<p>If your page is inline code, you don&#8217;t have to worry about the ASP namespace. The ASP namespace is a dynamic namespace that contains the controls you referenced with the &lt;%@ Reference %&gt; tag in the markup file.</p>
<p>I hope this helps anyone having problems referencing User Controls by classname in their code. I searched for quite a while and I only got answers like &#8220;don&#8217;t use code-behind if you want to do that&#8221; or &#8220;have all your controls implement a Interface and reference them by that interface&#8221;.</p>
<p>Please post any comments or questions. I check my email/comments daily, so a response should be pretty quick (usually about 1 business day maximum. If I&#8217;m at a computer working, I usually respond right away). You can also <a title="aaziz.org - contact" href="http://aaziz.org/index.php?page=contact">contact me</a> by email.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aaziz.org/referencing-aspnet-user-controls-in-code-behind/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

