<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - Tech Off - ASP.Net User control with codebehind not working</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Tech Off - ASP.Net User control with codebehind not working</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Thu, 20 Jun 2013 00:54:05 GMT</pubDate>
	<lastBuildDate>Thu, 20 Jun 2013 00:54:05 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>3</c9:totalResults>
	<c9:pageCount>-3</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Tech Off - ASP.Net User control with codebehind not working</title>
		<description><![CDATA[<p>I have several pages that use the same collection of controls, an Img, and a couple of labels. I figured I could write a Usercontrol that would wrap everything up. I also wanted to programmatically read properties of this control to tell me whether the
 image was horizontal (width&gt;height) or vertical (square counts as vertical).<br>
<br>
So I lay my controls into the ASCX file, and then&nbsp;go into the codebehind create some public (readonly properties). No compile errors.<br>
In my ascx file at the top I put this:<br>
<font face="Arial">&lt;%@ Control Inherits=&quot;uCtrlPreview&quot; src=&quot;uCtrlPreview.vb&quot; %&gt;<br>
</font><br>
<br>
I go into my first page (page1.aspx), give it a register tag, go down, put in my usercontrol tag. So far so good.<br>
<font face="Arial">&lt;%@ Register TagPrefix=&quot;UserControl&quot; TagName=&quot;PrevImg&quot; Src=&quot;previewImg.ascx&quot;
<br>
%&gt;<br>
...<br>
&lt;body&gt;<br>
...<br>
USERCONTROL:PrevImg id=&quot;Preview1&quot; runat=&quot;Server&quot;&gt;&lt;/USERCONTROL:PrevImg&gt;<br>
</font><br>
<br>
I go into my page's (page1.aspx)&nbsp;codebehind and put this line:<br>
<font face="Arial">Protected WithEvents Preview1 As uCtrlPreview<br>
<br>
<font face="Courier New">I get this message:</font><br>
The base class includes the field 'Preview1', but its type <br>
(ICUser.uCtrlPreview) is not compatible with the type of control <br>
(ASP.previewImg_ascx).<br>
<br>
</font><font face="Courier New">Any ideas?</font></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/29107-ASPNet-User-control-with-codebehind-not-working/29107#29107</link>
		<pubDate>Tue, 23 Nov 2004 22:08:13 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/29107-ASPNet-User-control-with-codebehind-not-working/29107#29107</guid>
		<dc:creator>qwert231</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/qwert231/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - ASP.Net User control with codebehind not working</title>
		<description><![CDATA[<p>I had the same problem today, but it is in C#.<br>
<br>
all you need to do is declare the control with it's name instead of declaring it as a user control. For instance, in my case:<br>
<br>
public class sniff : System.Web.UI.UserControl {<br>
<br>
code here<br>
<br>
}<br>
<br>
is then instantiated on my page thus:<br>
<br>
protected sniff ctrl_Sniff;<br>
<br>
I had tried to do it this way unsuccessfully:<br>
<br>
<p>protected System.Web.UI.UserControl ctrl_Sniff;<br>
<br>
HTH,<br>
<br>
~ Knute</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/29107-ASPNet-User-control-with-codebehind-not-working/d4317e4cdc5f4862ab389dea0116407d#d4317e4cdc5f4862ab389dea0116407d</link>
		<pubDate>Tue, 23 Nov 2004 22:42:10 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/29107-ASPNet-User-control-with-codebehind-not-working/d4317e4cdc5f4862ab389dea0116407d#d4317e4cdc5f4862ab389dea0116407d</guid>
		<dc:creator>Knute</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Knute/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - ASP.Net User control with codebehind not working</title>
		<description><![CDATA[<p>Nah, that's how I was instantiating it, as a new sniff.</p>
<p>Now, in the ASP.net book i have they say to put a ClassName=&quot;&quot; attribute in the ascx tag, like such:</p>
<p>&lt;%@ Control Inherits=&quot;uCtrlPreview&quot; src=&quot;uCtrlPreview.vb&quot; ClassName=&quot;SomeOtherName&quot; %&gt;</p>
<p>saying that it is needed in case we dynamically create the control on a page.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/29107-ASPNet-User-control-with-codebehind-not-working/da6d2fcdc2214d49b64f9dea011640a8#da6d2fcdc2214d49b64f9dea011640a8</link>
		<pubDate>Wed, 24 Nov 2004 14:13:21 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/29107-ASPNet-User-control-with-codebehind-not-working/da6d2fcdc2214d49b64f9dea011640a8#da6d2fcdc2214d49b64f9dea011640a8</guid>
		<dc:creator>qwert231</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/qwert231/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>