<?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>Trent Jones &#187; ASP.NET 4.0</title>
	<atom:link href="http://www.trentjones.net/index.php/tag/asp-net-4-0/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.trentjones.net</link>
	<description>DoSomething();</description>
	<lastBuildDate>Mon, 15 Mar 2010 19:27:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>ASP.NET 4.0 and Control IDs</title>
		<link>http://www.trentjones.net/index.php/2009/09/asp-net-4-0-and-control-ids/</link>
		<comments>http://www.trentjones.net/index.php/2009/09/asp-net-4-0-and-control-ids/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 19:35:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[codeproject]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[ASP.NET 4.0]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.trentjones.net/index.php/2009/09/asp-net-4-0-and-control-ids/</guid>
		<description><![CDATA[In .NET 4.0 there is a new option when adding controls to a page or user control: ClientIDMode.&#160; This property offers you four choices: Legacy, Static, Predictable, Inherit.&#160; Previously it was almost impossible to find the id of a control in a normal matter such as jQuery.&#160; Using Choosing Legacy will continue to issue an [...]]]></description>
			<content:encoded><![CDATA[<p>In .NET 4.0 there is a new option when adding controls to a page or user control: <strong>ClientIDMode</strong>.&#160; This property offers you four choices: Legacy, Static, Predictable, Inherit.&#160; Previously it was almost impossible to find the id of a control in a normal matter such as jQuery.&#160; Using </p>
<p>Choosing <strong>Legacy</strong> will continue to issue an ID in the same manner they were generated in previous version of ASP.NET, by concatenating the ID values of each parent naming container with the ID of the control.&#160; Setting the property to <strong>Static </strong>will use the exact value of the ID property of the server control.&#160; <strong>Predictable </strong>is used for controls that are data-bound controls such as repeater and also makes use of a <strong>ClientIDRowSuffix</strong> property.&#160; Using <strong>Inherit </strong>makes the control ID property use the setting of its parent control.</p>
<p>In the example below, two lists are created inside the ContentPlaceHolder of a page using the same DataSource. The first is using the default and the second uses the new property with <strong>Static </strong>set as the value.</p>
<pre class="brush: csharp;">
&lt;asp:Content ID=&quot;Content2&quot; ContentPlaceHolderID=&quot;ContentPlaceHolder1&quot; runat=&quot;server&quot;&gt;
    &lt;asp:XmlDataSource ID=&quot;LinkData&quot; runat=&quot;server&quot; XPath=&quot;Colors/Color&quot;&gt;
        &lt;Data&gt;
            &lt;Colors&gt;
                &lt;Color Name=&quot;Red&quot;/&gt;
                &lt;Color Name=&quot;Blue&quot;/&gt;
                &lt;Color Name=&quot;Yellow&quot;/&gt;
                &lt;Color Name=&quot;Green&quot; /&gt;
            &lt;/Colors&gt;
        &lt;/Data&gt;
    &lt;/asp:XmlDataSource&gt;
    &lt;asp:BulletedList ID=&quot;uxList&quot; DataSourceID=&quot;LinkData&quot; runat=&quot;server&quot; DataTextField=&quot;Name&quot; /&gt;
    &lt;asp:BulletedList ID=&quot;uxListStatic&quot; ClientIDMode=&quot;Static&quot; DataSourceID=&quot;LinkData&quot; runat=&quot;server&quot; DataTextField=&quot;Name&quot; /&gt;

    &lt;script type=&quot;text/javascript&quot;&gt;
        $(function() {
            $(&quot;#uxList&quot;).append(&quot;&lt;li&gt;Red&lt;/li&gt;&quot;);
            $(&quot;#uxListStatic&quot;).append(&quot;&lt;li&gt;Brown&lt;/li&gt;&quot;);
        });
    &lt;/script&gt;
&lt;/asp:Content&gt;
</pre>
<p>Here is the output of the page in HTML</p>
<pre class="brush: xml;">
&lt;div&gt;
    &lt;ul id=&quot;ctl00_ContentPlaceHolder1_uxList&quot;&gt;
        &lt;li&gt;Red&lt;/li&gt;&lt;li&gt;Blue&lt;/li&gt;&lt;li&gt;Yellow&lt;/li&gt;&lt;li&gt;Green&lt;/li&gt;
    &lt;/ul&gt;
    &lt;ul id=&quot;uxListStatic&quot;&gt;
        &lt;li&gt;Red&lt;/li&gt;&lt;li&gt;Blue&lt;/li&gt;&lt;li&gt;Yellow&lt;/li&gt;&lt;li&gt;Green&lt;/li&gt;
    &lt;/ul&gt;

    &lt;script type=&quot;text/javascript&quot;&gt;
    $(function() {
        $(&quot;#uxListStatic&quot;).append(&quot;&lt;li&gt;Brown&lt;/li&gt;&quot;);
    });
    &lt;/script&gt;
&lt;/div&gt;
</pre>
<p>And the corresponding view in the browser</p>
<pre class="brush: xml;">
•    Red
•    Blue
•    Yellow
•    Green

•    Red
•    Blue
•    Yellow
•    Green
•    Brown
</pre>
<p>Because of the generated tag on the first list jQuery can’t find the control to append to.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trentjones.net/index.php/2009/09/asp-net-4-0-and-control-ids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
