<?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>Scott Elkin &#187; ASP.NET</title>
	<atom:link href="http://scottelkin.com/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://scottelkin.com</link>
	<description>Tech, Love, Life</description>
	<lastBuildDate>Thu, 07 Apr 2011 23:02:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Render RadioButtonList as an Unordered List UL</title>
		<link>http://scottelkin.com/aspnet/render-radiobuttonlist-as-an-unordered-list-ul/</link>
		<comments>http://scottelkin.com/aspnet/render-radiobuttonlist-as-an-unordered-list-ul/#comments</comments>
		<pubDate>Sun, 28 Jan 2007 19:44:00 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">/archive/2007/01/28/Render-RadioButtonList-as-an-Unordered-List-UL.aspx</guid>
		<description><![CDATA[In my latest project, I found the need to use the RadioButtonList which spits out the absolute nastiest HTML to render it unusable (for me anyway). The control gives you to HTML options using the RepeatLayout attribute. Flow spits out a series of span&#8217;s and label&#8217;s with BR&#8217;s if you don&#8217;t specify RepeatDirection of Horizontal. [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>In my latest project, I found the need to use the RadioButtonList which spits out the absolute nastiest HTML to render it unusable (for me anyway).  The control gives you to HTML options using the RepeatLayout attribute.</p>
<p>Flow spits out a series of span&#8217;s and label&#8217;s with BR&#8217;s if you don&#8217;t specify RepeatDirection of Horizontal. And choosing Table gives you a nicely unaccessible table you can&#8217;t format easily. Because of these limitation&#8217;s, I have always stayed away from CheckBoxList and RadioButtonList controls.</p>
<p>My solution is to write my own RadioButtonList, but to spit it out as an Unordered List which I can style very easily horizontally or vertically, little or lots of padding, all with CSS.</p>
<p>I unfortunately have been forced to regress back to ASP.NET 1.1 and VB.NET for a little while until the company upgrades to 2.0.  Hence why I wrote the following instead of writing a CSS Control Adapter.</p>
<pre><code>Imports System
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace MyControls

 &lt;DefaultProperty("Text"), _
ToolboxData("&lt;{0}:ULRadioButtonList runat=server /&gt;") _
, Description("Creates a RadioButtonList using an Unordered List.")&gt; _
Public Class ULRadioButtonList
Inherits RadioButtonList

 Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)

//"SBE 01/28/2007:  just in case...not sure if this is needed or not
Controls.Clear()

//"SBE 01/28/2007:  not sure why I am leaving quotes as a param...I was just undecided if I would ever need to use " instead of "
Dim inputFormatString As String = "&lt;input id={0}{1}{0} name={0}{2}{0} type={0}radio{0} value={0}{3}{0} {4} /&gt;"
Dim labelFormatString As String = "&lt;label for={0}{1}{0}&gt;{2}&lt;/label&gt;"

//"SBE 01/28/2007:  if user sets the cssclass, add it to the &lt;ul&gt; tag
If (Not MyBase.CssClass Is Nothing AndAlso MyBase.CssClass &lt;&gt; "") Then
     writer.WriteLine("&lt;ul class="" &amp; MyBase.CssClass &amp; ""&gt;")
Else
     writer.WriteLine("&lt;ul&gt;")
End If

//"SBE 01/28/2007:  loop through the dataitems
For index As Integer = 0 To Items.Count - 1
     writer.Indent += 1
     writer.WriteLine("&lt;li&gt;")
     writer.Indent += 1

     Dim inputBuilder As New StringBuilder
</code><code>     </code><code>Dim labelBuilder As New StringBuilder
</code><code>     </code><code>Dim checked As String = ""

</code><code>     </code><code>If (Items(index).Selected) Then
     </code><code>     </code><code>checked = "checked"
</code><code>     </code><code>End If

</code><code>     </code><code>inputBuilder.AppendFormat(inputFormatString, """", MyBase.ClientID &amp; "_" &amp; index.ToString(), MyBase.UniqueID, Items(index).Value, checked)
</code><code>     </code><code>labelBuilder.AppendFormat(labelFormatString, """", MyBase.ClientID &amp; "_" &amp; index.ToString(), Items(index).Text)

</code><code>     </code><code>writer.WriteLine(inputBuilder.ToString())
</code><code>     </code><code>writer.WriteLine(labelBuilder.ToString())

</code><code>     </code><code>writer.Indent -= 1

</code><code>     </code><code>writer.WriteLine("&lt;/li&gt;")
</code><code>     </code><code>writer.WriteLine()
</code><code>     </code><code>writer.Indent -= 1

 Next

 writer.WriteLine("&lt;/ul&gt;")

 End Sub

 End Class

End Namespace

</code></pre>
<p>Before I started writing this, I found a beautiful website <a href="http://www.nikhedonia.com/notebook/entry/render-checkboxlist-as-an-unordered-list/">SimplyGold</a> who had already wrote something similar for the CheckBoxList. Thanks for saving me some time!</p>
<p><strong>Now playing:</strong> <a href="http://phobos.apple.com/WebObjects/MZSearch.woa/wa/advancedSearchResults?artistTerm=Menomena">Menomena</a> &#8211; <a href="http://phobos.apple.com/WebObjects/MZSearch.woa/wa/advancedSearchResults?songTerm=Muscle%20n%27%20Flo&amp;artistTerm=Menomena">Muscle n&#8217; Flo</a></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://scottelkin.com/aspnet/render-radiobuttonlist-as-an-unordered-list-ul/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Prevent Multiple Button Clicks in ASP.NET &#8211; How to Implement the Netflix &quot;Please Wait&#8230;&quot; Button</title>
		<link>http://scottelkin.com/aspnet/prevent-multiple-button-clicks-in-aspnet-how-to-implement-the-netflix-please-wait-button/</link>
		<comments>http://scottelkin.com/aspnet/prevent-multiple-button-clicks-in-aspnet-how-to-implement-the-netflix-please-wait-button/#comments</comments>
		<pubDate>Wed, 22 Dec 2004 02:44:00 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">/archive/2004/12/21/Prevent-Multiple-Button-Clicks-in-ASP.NET-_2D00_-How-to-Implement-the-Netflix-_2200_Please-Wait_2E002E002E002200_-Button.aspx</guid>
		<description><![CDATA[Netflix has a nice submit button so that when you click it, it changes to &#8220;Please Wait&#8230;&#8221; and disables itself to prevent you from clicking it again. before submit after submit I have problems all the time with my users doing this, and I never spent time trying to solve it. You would think all [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Netflix has a nice submit button so that when you click it, it changes to &#8220;Please Wait&#8230;&#8221; and disables itself to prevent you from clicking it again.</p>
<p align="center"><img src="/images/beforesubmit.gif" border="0" alt="" width="221" height="32" /><br />before submit</p>
<p align="center"><img src="/images/aftersubmit.gif" border="0" alt="" width="221" height="32" /><br />after submit</p>
<p>I have problems all the time with my users doing this, and I never spent time trying to solve it.</p>
<p> You would think all you need to do is wire up the button to some Javascript that would just disable the button.  That is what I thought.  The problem is once you do that, it prevents the postback from happening.</p>
<p>The way around this is to have a script run &#8220;OnBeforeUnload&#8221; so that it is still disables it late enough to not prevent postback.  The only problem with this is that it would disable the button on each Unload request.  We must solve this also.</p>
<p>I realize you can throw all this in a custom button, but since I just got this to work, here is my quick solution:</p>
<p>Put the following in your page&#39;s base class (assuming you have one).  If not, throw it in your codebehind.</p>
<pre>public void SetOnClickDisable(System.Web.UI.WebControls.Button control){				control.Attributes.Add("onclick","formSubmitted = true;");

	string javascript;

	javascript = "if (!formSubmitted) return;";	javascript += "var button = document.getElementById(&#39;" + control.ID + "&#39;);";	javascript += "button.value = \" Please Wait... \";";        javascript += "document.body.style.cursor = &#39;wait&#39;;";	javascript += "button.disabled = true;";

	RegisterStartupScript("onbeforeunload", "<script language=\"JavaScript\">var formSubmitted=false; window.attachEvent(\"onbeforeunload\",function(){" + javascript + "});</script>");}
</pre>
<p>The first line tells the function that gets called that the button was pressed triggering postback.  This will prevent every Unload from running this function.  The rest assembles the function to disable the Button you pass into it.</p>
<p>Next, call it from your page.</p>
<pre>	base.SetOnClickDisable(SubmitSearch);
</pre>
<p>Thats all you need to get it working.  Now some cool css to make it look like a Netflix button.  In your css file (or in the page if you want) put:</p>
<pre>.netflix-button {	font: 11px arial,helvetica, sans-serif; 	font-weight: bold; 	letter-spacing: 1; 	color: #333333; 	cursor: pointer; 	cursor: hand; 	background-image : url(/img/button.gif); 	background-color : White;}
</pre>
<p>And then in your aspx page put:</p>
<pre><asp:button id="SubmitSearch" class="netflix-button" runat="server" Text="Search Orders" />										</pre>
<p>You also need the background for the image which you can get <a href="http://a408.g.akamai.net/f/408/1284/24h/image.netflix.com/NetFlix_Assets/testing/newRaterExp/form_btn_tile.gif" target="_blank">here</a> and save it in the path you specify in your css .netflix-button class above.</p>
<p>***Understand that this is a Netflix image, so ONLY use this as an example.  In fact, I have no right to even link to it, but I figure that it is easier to show it this way, and Netflix won&#39;t care as long as we don&#39;t rip it off.</p>
<p>Note that this works with the validation controls also.  The buttons will not be disabled if the postback is stopped in the validation stage.</p>
<p>The main problem right now is that this will only work for one button on a page.  It isn&#39;t the worst deal in the world because it isn&#39;t that often that I have multiple buttons on a page that spawn long running operations.  In any case, if anyone wants to solve that, go for it!</p>
<p>If I left anything out, let me know as this works successfully over here.  And if it works, let me know too!</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://scottelkin.com/aspnet/prevent-multiple-button-clicks-in-aspnet-how-to-implement-the-netflix-please-wait-button/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Binding a DropDownList to an Enumeration</title>
		<link>http://scottelkin.com/aspnet/binding-a-dropdownlist-to-an-enumeration/</link>
		<comments>http://scottelkin.com/aspnet/binding-a-dropdownlist-to-an-enumeration/#comments</comments>
		<pubDate>Wed, 18 Aug 2004 08:09:00 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">/archive/2004/08/18/Binding-a-DropDownList-to-an-Enumeration.aspx</guid>
		<description><![CDATA[Ok, well its not really binding to it. No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Ok, well its not really <em>binding</em> to it.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://scottelkin.com/aspnet/binding-a-dropdownlist-to-an-enumeration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>String to Enum</title>
		<link>http://scottelkin.com/aspnet/string-to-enum/</link>
		<comments>http://scottelkin.com/aspnet/string-to-enum/#comments</comments>
		<pubDate>Thu, 15 Jul 2004 16:58:00 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">/archive/2004/07/15/String-to-Enum.aspx</guid>
		<description><![CDATA[I have to do this now and then and each time I don&#39;t write this code perfect the first time. No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I have to do this now and then and each time I don&#39;t write this code perfect the first time.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://scottelkin.com/aspnet/string-to-enum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)

Served from: scottelkin.com @ 2012-05-17 23:32:55 -->
