<?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>Toars &#187; Master Page</title>
	<atom:link href="http://www.toars.com/tag/master-page/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.toars.com</link>
	<description>I will smile to the world ^o^</description>
	<lastBuildDate>Fri, 06 May 2011 08:50:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to access controls in Master Page / Strongly typed Master Page</title>
		<link>http://www.toars.com/2009/08/how-to-access-controls-in-master-page-strongly-typed-master-page/</link>
		<comments>http://www.toars.com/2009/08/how-to-access-controls-in-master-page-strongly-typed-master-page/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 09:46:40 +0000</pubDate>
		<dc:creator>Xin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Master Page]]></category>
		<category><![CDATA[Strongly Typed]]></category>

		<guid isPermaLink="false">http://www.toars.com/?p=105</guid>
		<description><![CDATA[It is very simple for a page to access the controls in its Master Page. For example, we can use this way: ((Label)(Master.FindControl(“LblTitle”))).Text = “My Application”; or (Master.FindControl(“LblTitle”) as Label).Text = “My Application”; Can you see that? first, it is not very clean look, second, no intellisence for the LblTitle (the control ID). I don’t [...]]]></description>
			<content:encoded><![CDATA[<p>It is very simple for a page to access the controls in its Master Page.</p>
<p>For example, we can use this way:</p>
<pre>((Label)(Master.FindControl(“LblTitle”))).Text = “My Application”;</pre>
<p>or</p>
<pre>(Master.FindControl(“LblTitle”) as Label).Text = “My Application”;</pre>
<p><br/><br />
Can you see that? first, it is not very clean look, second, no intellisence for the LblTitle (the control ID). I don’t like this way of accessing the controls in the Master Page.</p>
<p>I would rather to make the Master Page strongly typed, and create properties or method in the Master Page.</p>
<p>In order to make the Master Page strongly typed, we need to declare the MasterType in the Aspx pages. For example:</p>
<pre>&lt;%@ MasterType virtualpath="~/MasterPages/Support.Master" %&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.toars.com/2009/08/how-to-access-controls-in-master-page-strongly-typed-master-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

