<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: 3-State CheckBox using Microsoft AJAX</title>
	<atom:link href="http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/</link>
	<description>It&#039;s always time to upgrade!</description>
	<lastBuildDate>Sat, 19 Nov 2011 23:30:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Chad</title>
		<link>http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/comment-page-1/#comment-2027</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Fri, 28 Oct 2011 22:15:47 +0000</pubDate>
		<guid isPermaLink="false">http://chadscharf.com/post.aspx?id=565b0d14-08af-4b2d-8677-11163000d088#comment-2027</guid>
		<description>Thanks for the head&#039;s up Sebastien, the link has been fixed and the source code can now be downloaded: &lt;a href=&quot;http://www.chadscharf.com/files/ThreeStateCheckBox.zip&quot; rel=&quot;nofollow&quot;&gt;http://www.chadscharf.com/files/ThreeStateCheckBox.zip&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Thanks for the head&#8217;s up Sebastien, the link has been fixed and the source code can now be downloaded: <a href="http://www.chadscharf.com/files/ThreeStateCheckBox.zip" rel="nofollow">http://www.chadscharf.com/files/ThreeStateCheckBox.zip</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastien DErrico</title>
		<link>http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/comment-page-1/#comment-2026</link>
		<dc:creator>Sebastien DErrico</dc:creator>
		<pubDate>Fri, 28 Oct 2011 17:27:19 +0000</pubDate>
		<guid isPermaLink="false">http://chadscharf.com/post.aspx?id=565b0d14-08af-4b2d-8677-11163000d088#comment-2026</guid>
		<description>Hello,

This is a great article.

Unfortunately, the source code does not seem to be available.

Is it possible to download it somewhere?

Thank you,
Have a great day!
Sébastien</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>This is a great article.</p>
<p>Unfortunately, the source code does not seem to be available.</p>
<p>Is it possible to download it somewhere?</p>
<p>Thank you,<br />
Have a great day!<br />
Sébastien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad</title>
		<link>http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/comment-page-1/#comment-1672</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Tue, 19 Apr 2011 12:37:01 +0000</pubDate>
		<guid isPermaLink="false">http://chadscharf.com/post.aspx?id=565b0d14-08af-4b2d-8677-11163000d088#comment-1672</guid>
		<description>That&#039;s great. I hadn&#039;t had a chance to look at it yet so I&#039;m glad you were able to work around the issue. I don&#039;t see any problems with the way you accomplished it. I really need to get around to re-writing this as a jQuery plug-in at some point when I have some time; it would be so much cleaner.</description>
		<content:encoded><![CDATA[<p>That&#8217;s great. I hadn&#8217;t had a chance to look at it yet so I&#8217;m glad you were able to work around the issue. I don&#8217;t see any problems with the way you accomplished it. I really need to get around to re-writing this as a jQuery plug-in at some point when I have some time; it would be so much cleaner.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Demetrio</title>
		<link>http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/comment-page-1/#comment-1671</link>
		<dc:creator>Demetrio</dc:creator>
		<pubDate>Tue, 19 Apr 2011 00:49:44 +0000</pubDate>
		<guid isPermaLink="false">http://chadscharf.com/post.aspx?id=565b0d14-08af-4b2d-8677-11163000d088#comment-1671</guid>
		<description>Hey Chad,

Just thought I&#039;d share my workaround for the problem just in case others are grapling with it. I removed insertion of the $create statement buy not returning anything in the GetScriptDescriptors() function. Instead I wired up an event on the server for the imagebutton:

checkBox.Attributes.Add(&quot;onclick&quot;, &quot;ThreeStateCheckBox_onButtonClick(event, this)&quot;)

Then added a function to the javascript file to handle the creation and disposal of the javascript ThreeStateCheckbox object which passes the event to the object for handling. Let me know if you see any issues with this workaround.

function ThreeStateCheckBox_onButtonClick(event, eventElement) {

    //use the create function here rather than using the GetScriptDescriptors as the event is tied to the checkbox at the server
    var hiddenElementId = eventElement.id.substring(0, eventElement.id.length - &#039;_CheckBox&#039;.length) + &quot;_hidden&quot;;
    var CheckState = eventElement.getAttribute(&#039;checked&#039;);
    var NullCheckBox = $create(ChadScharf._ThreeStateCheckBox, { &quot;buttonId&quot;: eventElement.id, &quot;hiddenFieldId&quot;: hiddenElementId, &quot;checked&quot;: CheckState }, null, null, eventElement);

    //pass the event to the object, then dispose to avoid duplicate objects and memory leaks
    NullCheckBox._onButtonClick(event);
    NullCheckBox.dispose();
}</description>
		<content:encoded><![CDATA[<p>Hey Chad,</p>
<p>Just thought I&#8217;d share my workaround for the problem just in case others are grapling with it. I removed insertion of the $create statement buy not returning anything in the GetScriptDescriptors() function. Instead I wired up an event on the server for the imagebutton:</p>
<p>checkBox.Attributes.Add(&#8220;onclick&#8221;, &#8220;ThreeStateCheckBox_onButtonClick(event, this)&#8221;)</p>
<p>Then added a function to the javascript file to handle the creation and disposal of the javascript ThreeStateCheckbox object which passes the event to the object for handling. Let me know if you see any issues with this workaround.</p>
<p>function ThreeStateCheckBox_onButtonClick(event, eventElement) {</p>
<p>    //use the create function here rather than using the GetScriptDescriptors as the event is tied to the checkbox at the server<br />
    var hiddenElementId = eventElement.id.substring(0, eventElement.id.length &#8211; &#8216;_CheckBox&#8217;.length) + &#8220;_hidden&#8221;;<br />
    var CheckState = eventElement.getAttribute(&#8216;checked&#8217;);<br />
    var NullCheckBox = $create(ChadScharf._ThreeStateCheckBox, { &#8220;buttonId&#8221;: eventElement.id, &#8220;hiddenFieldId&#8221;: hiddenElementId, &#8220;checked&#8221;: CheckState }, null, null, eventElement);</p>
<p>    //pass the event to the object, then dispose to avoid duplicate objects and memory leaks<br />
    NullCheckBox._onButtonClick(event);<br />
    NullCheckBox.dispose();<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Demetrio</title>
		<link>http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/comment-page-1/#comment-1664</link>
		<dc:creator>Demetrio</dc:creator>
		<pubDate>Wed, 13 Apr 2011 22:42:40 +0000</pubDate>
		<guid isPermaLink="false">http://chadscharf.com/post.aspx?id=565b0d14-08af-4b2d-8677-11163000d088#comment-1664</guid>
		<description>Thanks for your reply Chad.

The problem with the $Create being placed in the header is that if the user reloads a certain section of the page (by clicking the same link which causes the partial postback) and the same CheckBoxes get loaded, you get duplicate ids and ajax throws an exception. There&#039;s also no guarantee that the Checkboxes get loaded on the initial display of the page as it depends on what section they are looking at. Is there a way to use the control without generating the $Create statement (i.e. no GetScriptDescriptors). 

The best way might be to wire up the javascript click event on the server which would change the image for the check box.</description>
		<content:encoded><![CDATA[<p>Thanks for your reply Chad.</p>
<p>The problem with the $Create being placed in the header is that if the user reloads a certain section of the page (by clicking the same link which causes the partial postback) and the same CheckBoxes get loaded, you get duplicate ids and ajax throws an exception. There&#8217;s also no guarantee that the Checkboxes get loaded on the initial display of the page as it depends on what section they are looking at. Is there a way to use the control without generating the $Create statement (i.e. no GetScriptDescriptors). </p>
<p>The best way might be to wire up the javascript click event on the server which would change the image for the check box.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad</title>
		<link>http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/comment-page-1/#comment-1663</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Wed, 13 Apr 2011 15:28:28 +0000</pubDate>
		<guid isPermaLink="false">http://chadscharf.com/post.aspx?id=565b0d14-08af-4b2d-8677-11163000d088#comment-1663</guid>
		<description>You can do this from the server side as well as the client or render a script inline. The $create should remain at the top in the header, however you can wire up additional events in your own script with the update panel to make this work right perhaps:

&lt;script type=&quot;text/javascript&quot;&gt;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function() {
    if (prm.get_isInAsyncPostBack) {
        $addHandler($get(&quot;..._p_90_ctl00_LeftLowerLimbSelection_checkBox&quot;), &quot;checkChanged&quot;, function() {
            alert(&quot;This is a test...&quot;);
        });
    }
});
&lt;/script&gt;

I&#039;ll have to play with this a little more later on, it&#039;s been a long time since I&#039;ve used this control now with MVC out ;-).

~ Chad</description>
		<content:encoded><![CDATA[<p>You can do this from the server side as well as the client or render a script inline. The $create should remain at the top in the header, however you can wire up additional events in your own script with the update panel to make this work right perhaps:</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var prm = Sys.WebForms.PageRequestManager.getInstance();<br />
prm.add_endRequest(function() {<br />
    if (prm.get_isInAsyncPostBack) {<br />
        $addHandler($get(&#8220;&#8230;_p_90_ctl00_LeftLowerLimbSelection_checkBox&#8221;), &#8220;checkChanged&#8221;, function() {<br />
            alert(&#8220;This is a test&#8230;&#8221;);<br />
        });<br />
    }<br />
});<br />
&lt;/script&gt;</p>
<p>I&#8217;ll have to play with this a little more later on, it&#8217;s been a long time since I&#8217;ve used this control now with MVC out <img src='http://www.chadscharf.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p>~ Chad</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Demetrio</title>
		<link>http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/comment-page-1/#comment-1662</link>
		<dc:creator>Demetrio</dc:creator>
		<pubDate>Wed, 13 Apr 2011 06:38:15 +0000</pubDate>
		<guid isPermaLink="false">http://chadscharf.com/post.aspx?id=565b0d14-08af-4b2d-8677-11163000d088#comment-1662</guid>
		<description>Hi Chad,
Excellent article, one of the few thorough papers on this rare topic.

I&#039;m having an issue hosting the checkbox in an update panel. The ChadScharf$_ThreeStateCheckBox$_onButtonClick event doesn&#039;t fire (which means that a postback is generated on each click). I&#039;ve narrowed the reason down to the position of the rendering of the $create method for the control on the client side. For some reason it is being rendered in the head section of the html. This means that the script is run before the control is rendered on the client and therefore the event doesn&#039;t wire up. Is there any way to force the create method to render elsewhere? Thanks in advance.



    
    
    
        Sys.Application.add_init(function () {
            $create(ChadScharf._ThreeStateCheckBox, { &quot;autoPostBack&quot;: false, &quot;buttonId&quot;: &quot;EvaluationWizard1_QuestionSection1_SectionQuestionList_EvaluationWizard1_QuestionSection1_SectionQuestionList_p_90_ctl00_LeftLowerLimbSelection_checkBox&quot;, &quot;checked&quot;: &quot;Blank&quot;, &quot;dataKey&quot;: &quot;&quot;, &quot;hiddenFieldId&quot;: &quot;EvaluationWizard1_QuestionSection1_SectionQuestionList_EvaluationWizard1_QuestionSection1_SectionQuestionList_p_90_ctl00_LeftLowerLimbSelection_hidden&quot;, &quot;imgBlank&quot;: &quot;/CPReview.WebUi/WebResource.axd?d=QEBJ-MkVr9cLW8K4ZDydlhzT3yBZD0xSTptHhHNB-cLbApc4M3fflYB8i6Vm8P-Y7C-L0Mbtskf_4Bwkib5SSYIe9cKREehIPYNESaQgjiGNUIlDvef6gBY-qzxtGZfCEnLOYS2irHyieTVG8BbTgQ2&amp;t=634383084076491083&quot;, &quot;imgChecked&quot;: &quot;/CPReview.WebUi/WebResource.axd?d=2ZejVv3OrvYY9FnpydKPFXnMS2jAMj3Q8p3D8F55NuSXLnQJC4EAiEZ1Se4IBv0brxcq2iYiie8DofDoTrZgdvbTMmYxzJX9IbmhGW1cmJOuaiPlTJfarEqFreVf6wXq5k2RuEp6Keosa6zalv27hA2&amp;t=634383084076491083&quot;, &quot;imgUnchecked&quot;: &quot;/CPReview.WebUi/WebResource.axd?d=hWTJsDUBPgUDCUEeq3Dagd4FDCRzJJdB6CRnrn2zWDFaxLdylQUhSPWYt1Om7dL2w7XSvrY0_b4cPBj0Qy82iU4VguvhTw0vYoA6KzIE2Gy48KDDRIpkUnFOLwsqz8BykTrkKo7l2NE48CD9gRQepw2&amp;t=634383084076491083&quot; }, null, null, $get(&quot;EvaluationWizard1_QuestionSection1_SectionQuestionList_EvaluationWizard1_QuestionSection1_SectionQuestionList_p_90_ctl00_LeftLowerLimbSelection&quot;));
        });
    
    
        body content here
    
</description>
		<content:encoded><![CDATA[<p>Hi Chad,<br />
Excellent article, one of the few thorough papers on this rare topic.</p>
<p>I&#8217;m having an issue hosting the checkbox in an update panel. The ChadScharf$_ThreeStateCheckBox$_onButtonClick event doesn&#8217;t fire (which means that a postback is generated on each click). I&#8217;ve narrowed the reason down to the position of the rendering of the $create method for the control on the client side. For some reason it is being rendered in the head section of the html. This means that the script is run before the control is rendered on the client and therefore the event doesn&#8217;t wire up. Is there any way to force the create method to render elsewhere? Thanks in advance.</p>
<p>        Sys.Application.add_init(function () {<br />
            $create(ChadScharf._ThreeStateCheckBox, { &#8220;autoPostBack&#8221;: false, &#8220;buttonId&#8221;: &#8220;EvaluationWizard1_QuestionSection1_SectionQuestionList_EvaluationWizard1_QuestionSection1_SectionQuestionList_p_90_ctl00_LeftLowerLimbSelection_checkBox&#8221;, &#8220;checked&#8221;: &#8220;Blank&#8221;, &#8220;dataKey&#8221;: &#8220;&#8221;, &#8220;hiddenFieldId&#8221;: &#8220;EvaluationWizard1_QuestionSection1_SectionQuestionList_EvaluationWizard1_QuestionSection1_SectionQuestionList_p_90_ctl00_LeftLowerLimbSelection_hidden&#8221;, &#8220;imgBlank&#8221;: &#8220;/CPReview.WebUi/WebResource.axd?d=QEBJ-MkVr9cLW8K4ZDydlhzT3yBZD0xSTptHhHNB-cLbApc4M3fflYB8i6Vm8P-Y7C-L0Mbtskf_4Bwkib5SSYIe9cKREehIPYNESaQgjiGNUIlDvef6gBY-qzxtGZfCEnLOYS2irHyieTVG8BbTgQ2&amp;t=634383084076491083&#8243;, &#8220;imgChecked&#8221;: &#8220;/CPReview.WebUi/WebResource.axd?d=2ZejVv3OrvYY9FnpydKPFXnMS2jAMj3Q8p3D8F55NuSXLnQJC4EAiEZ1Se4IBv0brxcq2iYiie8DofDoTrZgdvbTMmYxzJX9IbmhGW1cmJOuaiPlTJfarEqFreVf6wXq5k2RuEp6Keosa6zalv27hA2&amp;t=634383084076491083&#8243;, &#8220;imgUnchecked&#8221;: &#8220;/CPReview.WebUi/WebResource.axd?d=hWTJsDUBPgUDCUEeq3Dagd4FDCRzJJdB6CRnrn2zWDFaxLdylQUhSPWYt1Om7dL2w7XSvrY0_b4cPBj0Qy82iU4VguvhTw0vYoA6KzIE2Gy48KDDRIpkUnFOLwsqz8BykTrkKo7l2NE48CD9gRQepw2&amp;t=634383084076491083&#8243; }, null, null, $get(&#8220;EvaluationWizard1_QuestionSection1_SectionQuestionList_EvaluationWizard1_QuestionSection1_SectionQuestionList_p_90_ctl00_LeftLowerLimbSelection&#8221;));<br />
        });</p>
<p>        body content here</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kees C. Bakker</title>
		<link>http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/comment-page-1/#comment-1537</link>
		<dc:creator>Kees C. Bakker</dc:creator>
		<pubDate>Thu, 17 Feb 2011 10:11:46 +0000</pubDate>
		<guid isPermaLink="false">http://chadscharf.com/post.aspx?id=565b0d14-08af-4b2d-8677-11163000d088#comment-1537</guid>
		<description>Loved the article! Very useful in showing how to build a rich control. Keep on the good work!</description>
		<content:encoded><![CDATA[<p>Loved the article! Very useful in showing how to build a rich control. Keep on the good work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad</title>
		<link>http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/comment-page-1/#comment-1170</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Thu, 01 Jul 2010 14:26:41 +0000</pubDate>
		<guid isPermaLink="false">http://chadscharf.com/post.aspx?id=565b0d14-08af-4b2d-8677-11163000d088#comment-1170</guid>
		<description>[DefaultValue(CheckedState.Blank)]
[Bindable(true, BindingDirection.TwoWay)]
[Themeable(false)]
public bool? IsChecked
{
	#region IsChecked

	get
	{
		switch (Checked)
		{
			case CheckedState.Checked: return true;
			case CheckedState.Unchecked: return false;
			case CheckedState.Blank:
			default: return null;
		}
	}
	set
	{
		Checked = value == null ? CheckedState.Blank : value.Value ? CheckedState.Checked : CheckedState.Unchecked;
	}

	#endregion
}</description>
		<content:encoded><![CDATA[<p>[DefaultValue(CheckedState.Blank)]<br />
[Bindable(true, BindingDirection.TwoWay)]<br />
[Themeable(false)]<br />
public bool? IsChecked<br />
{<br />
	#region IsChecked</p>
<p>	get<br />
	{<br />
		switch (Checked)<br />
		{<br />
			case CheckedState.Checked: return true;<br />
			case CheckedState.Unchecked: return false;<br />
			case CheckedState.Blank:<br />
			default: return null;<br />
		}<br />
	}<br />
	set<br />
	{<br />
		Checked = value == null ? CheckedState.Blank : value.Value ? CheckedState.Checked : CheckedState.Unchecked;<br />
	}</p>
<p>	#endregion<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad</title>
		<link>http://www.chadscharf.com/index.php/2008/10/3-state-checkbox-using-microsoft-ajax/comment-page-1/#comment-1159</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Thu, 01 Jul 2010 01:42:19 +0000</pubDate>
		<guid isPermaLink="false">http://chadscharf.com/post.aspx?id=565b0d14-08af-4b2d-8677-11163000d088#comment-1159</guid>
		<description>You could easily add a Text property to the control, sure. I would add a Label control positioned relative to the image button, setting the target control Id = the image button&#039;s ID. This way the lable will act like a true form label, similar to how ASP.NET renders a true asp:CheckBox control.

As far as setting the 3-way state using a nullable boolean value, that should be easy as well. Something like this should suffice; (where myBitField is a nullable boolean, (bool? myBitField)):

myCheckBox.Checked = myBitField == null ? CheckedState.Blank : myBitField.Value ? CheckedState.Checked : CheckedState.Unchecked;

And then just reversing that the other way to get the value back out. You could also scrap the enumeration and simply use a Nullable property instead, blank = null, checked = true, unchecked = false. It should be fairly simple to switch the binding from the enumeration with the hidden field (which can have a blank string as its value anyway).

Thanks,
Chad</description>
		<content:encoded><![CDATA[<p>You could easily add a Text property to the control, sure. I would add a Label control positioned relative to the image button, setting the target control Id = the image button&#8217;s ID. This way the lable will act like a true form label, similar to how ASP.NET renders a true asp:CheckBox control.</p>
<p>As far as setting the 3-way state using a nullable boolean value, that should be easy as well. Something like this should suffice; (where myBitField is a nullable boolean, (bool? myBitField)):</p>
<p>myCheckBox.Checked = myBitField == null ? CheckedState.Blank : myBitField.Value ? CheckedState.Checked : CheckedState.Unchecked;</p>
<p>And then just reversing that the other way to get the value back out. You could also scrap the enumeration and simply use a Nullable property instead, blank = null, checked = true, unchecked = false. It should be fairly simple to switch the binding from the enumeration with the hidden field (which can have a blank string as its value anyway).</p>
<p>Thanks,<br />
Chad</p>
]]></content:encoded>
	</item>
</channel>
</rss>

