<?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; Programming</title> <atom:link href="http://scottelkin.com/category/programming/feed/" rel="self" type="application/rss+xml" /><link>http://scottelkin.com</link> <description>Tech, Love, Life</description> <lastBuildDate>Sun, 25 Apr 2010 16:29:15 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Integrating Forums with WordPress</title><link>http://scottelkin.com/programming/integrating-forums-with-wordpress/</link> <comments>http://scottelkin.com/programming/integrating-forums-with-wordpress/#comments</comments> <pubDate>Sat, 24 Apr 2010 07:26:56 +0000</pubDate> <dc:creator>Scott</dc:creator> <category><![CDATA[Programming]]></category><guid isPermaLink="false">http://scottelkin.com/?p=361</guid> <description><![CDATA[There are three viable options if you want to leverage WordPress as your Content Management System, yet want to offer your users a way to interact in a forum. bbPress phpbb vBulletin bbPress bbPress is a very lean forum solution for WordPress written by Automatic.  It is a great idea for a quick and dirty [...]No related posts.]]></description> <content:encoded><![CDATA[<p>There are three viable options if you want to leverage WordPress as your Content Management System, yet want to offer your users a way to interact in a forum.</p><ul><li>bbPress</li><li>phpbb</li><li>vBulletin</li></ul><h3>bbPress</h3><p><img alt="bbPress logo" class="alignleft" src="/wp-content/uploads/bbPress.jpg"/><br /> bbPress is a very lean forum solution for WordPress written by Automatic.  It is a great idea for a quick and dirty forum that works.  Theming works similarly to WordPress &#8211; so if you enjoy writing themes in WordPress, this will be easy.</p><p>I had to install it in a subdirectory.  Trying to install it in the same directory as WordPress causes a battle over index.php since they both need it.</p><p>For the most part, you just need to <a href="http://bbpress.org/download/">install it</a>, and <a href="http://bbpress.org/documentation/installation/">follow the directions</a>.  Here are my tips:</p><ol><li>Make sure bb-config.php is writeable.  I didn&#8217;t find that out I needed to until I got an error message.</li><li>When it is asking you for the &#8220;salt&#8221; strings, you can go here to view it if needed:  /wp-admin/options.php</li><li>I didnt read this until after my first attempt, but by following this you should be fine:<br /> <a href="http://www.wpmods.com/integrate-wordpress-bbpress">http://www.wpmods.com/integrate-wordpress-bbpress</a></li></ol><p><strong>Mods:</strong></p><p><a href="http://forums.atsutane.net/topic/bbpress-latest-discussion-for-wordpress">Latest Discussion For WordPress</a> &#8211; This will allow you to see the forum posts in your wordpress sidebar</p><p><strong>Notes:</strong></p><p>If you can&#8217;t get to the bbPress Admin Site after integration, just delete the following keys in your bbPress database that refer to the WordPress database.</p><p><img alt="bb-press-database-fix" class="alignleft" src="/wp-content/uploads/bb-press-fix.jpg"/></p><p>After spending several hours trying to figure out how I broke the bbPress Admin Site, I gave up and just installed bbPress into the WordPress database.</p><h3>phpBB</h3><p><img alt="phpBB logo" class="alignleft" src="/wp-content/uploads/logo_phpbb.png"/><br /> phpBB is a much more robust (bloated) forum.  And the integration is done with one major plugin, <a href="http://www.wp-united.com/get-wp-united/">WP-United</a>.</p><p>You must follow directions exactly.  There are about 30 files you need to edit, and if you zone out and start watching ESPN, it isn&#8217;t going to end happy for you.</p><p>There are over 20 code changes you need to make in the phpBB files, and the instructions sometimes say &#8220;replace&#8221;, &#8220;add before&#8221; and &#8220;add after&#8221;.  It is easy to overlook these and add your code after a line instead of before.</p><p>Once it is installed, you can use various <a href="http://www.wp-united.com/template-tags/">Template Tags</a> in your WordPress theme to show forum posts and statistics.</p><p>Theming is also really nice &#8211; there are files you can edit just like bbPress.  You just need to learn some of the phpBB conventions they use in the HTML.</p><p><strong>Notes</strong></p><ul><li> I couldn&#8217;t get the logged in user to show logged in under comments.</li><li>Basic features like adding users by an administrator requires an additional plugin.</li><li>If you have to upgrade phpBB in the future, you will have to make all those edits all over again.</li></ul><h3>vBulletin</h3><p><img alt="vBulletin logo" class="alignleft" src="/wp-content/uploads/vBulletin.jpg"/><br /> vBulletin is extremely robust, but so much so that it is really hard to figure out where to configure various settings.  But because of the large user community, a simple google or vBulletin forum search will tell you where to look.</p><p>vBulletin is not free like phpBB or bbPress, but you do get what you pay for.  You get free Technical Support, and for a little more money you can even get free telephone support.</p><p>You can view an <a href="http://www.vbulletin.com/admindemo.php">online demo</a> on their site before you purchase, and if you buy it and change your mind, you can get your money back within 30 days.</p><p>The major benefit with vBulletin is that it opens the door for you to start charging for paid membership.  vBulletin integrates with many payment providers and can charge one time or recurring.</p><p><strong>Mods</strong></p><p><a href="http://www.vbulletin.org/forum/showthread.php?t=205388&amp;highlight=wordpress+bridge">vBulletin-WordPress Bridge</a>:  This will map vBulletin user groups to WordPress user groups and allow single sign on.  Just make sure you follow the instructions and go to fast.  (Do the test post before you go and turn it on all the way.)</p><p><a href="http://www.vbulletin.org/forum/showthread.php?t=228089&amp;highlight=wordpress+login">Simple vB Login</a> &#8211; This gives us our login form on the WordPress side.</p><p>If you want to access the vBulletin user, you need to put &#8220;global $vbulletin;&#8221; in the login_inc.php and possibly the header.php of your theme.</p><p><a href="http://wordpress.org/extend/plugins/hidepost/">Hidepost</a> (custom) &#8211; The normal Hidepost plugin allows you to hide content from various user groups.  I changed hidepost to look at $vbulletin user instead of wordpress user (although you may not always have to do that).</p><p><strong>Notes:</strong></p><ul><li>Logging into vBulletin is confusing.  You can login at vbulletin.com, but all your user information is on members.vbulletin.com.  And then you have to add an email address to your account to access vbulletin.org where the user community and mods are located.</li></ul><h3>Summary</h3><ul><li>If you think a forum would be nice, but you don&#8217;t know if it will be successful or not, go with bbPress.</li><li>If you want a full featured forum, no matter how complex, go with vBulletin.</li><li>If you think you would EVER want to have a paid membership with hidden content, you must use vBulletin.</li><li>If you like the idea that you can email or call someone for help, use vBulletin.</li><li>If you like the features of vBulletin, but you REALLY don&#8217;t want to spend the money, then go with phpBB.</li></ul><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://scottelkin.com/programming/integrating-forums-with-wordpress/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>How To Properly Setup and Configure Godaddy DNS Settings</title><link>http://scottelkin.com/programming/how-to-properly-configure-godaddy-dns-settings/</link> <comments>http://scottelkin.com/programming/how-to-properly-configure-godaddy-dns-settings/#comments</comments> <pubDate>Wed, 22 Jul 2009 21:29:25 +0000</pubDate> <dc:creator>Scott</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[dns]]></category> <category><![CDATA[godaddy]]></category> <category><![CDATA[reverse dns]]></category><guid isPermaLink="false">http://scottelkin.com/?p=329</guid> <description><![CDATA[If you buy domains through Godaddy, but host the website and mail somewhere else, chances are you had to edit your DNS settings. Up until a few weeks ago I had been doing it wrong.  It was working, for the most part, but some things like reverse dns lookups would fail, and strange errors would [...]No related posts.]]></description> <content:encoded><![CDATA[<p>If you buy domains through Godaddy, but host the website and mail somewhere else, chances are you had to edit your DNS settings.</p><p>Up until a few weeks ago I had been doing it wrong.  It was working, for the most part, but some things like reverse dns lookups would fail, and strange errors would sometimes crop up.</p><p>When you buy your domain through Godaddy, find your way into Total DNS Control.  You will see a page similar to this:</p><p><img class="aligncenter" title="Godaddy Default DNS" src="/images/godaddy-dns-before.jpg" alt="" width="600" height="601" /></p><p>Scary, that&#8217;s for sure.</p><p>Now, before we can edit this, you need to know where your website is going to be hosted.  So if you are hosting at Hostgator.com for example, you would sign up with them and they would give you the IP Address to use for your site.</p><p>Armed with that IP Address, you can start editing your DNS Record.  Keep in mind that this is not gospel &#8211; your mileage may vary.  This works for me everytime when I point to a website I am setting up in CPanel and also need to manage the mail.  If you want your mail through Godaddy, then you do not want to make these changes.</p><ol><li>Switch to advanced mode so that you can edit more than one line at a time.</li><li>Change the @ A(Host) @ record to your new IP.</li><li>Delete every CNAME except for www and ftp</li><li>Add the mail A(Host) Record for mail pointing to the same new ip.</li><li>Delete the MX record with Priority 0.</li><li>Change the priority 10 record to mail.YOU-DOMAIN-NAME.COM</li><li>Add new SPF record and follow the following prompts<ol><li>Choose &#8220;an ISP or other mail provider&#8221;</li><li>inbound tab: all inbound servers may send mail</li><li>outbound tab: all addresses in A records</li><li>PTR tab: include PTR</li><li>The resultant line should look like &#8220;v=spf1 a mx ptr ~all&#8221;</li></ol></li></ol><p>Your DNS should now look like this:</p><p><img class="aligncenter" title="Godaddy DNS After" src="/images/godaddy-dns-after.jpg" alt="" width="600" /></p><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://scottelkin.com/programming/how-to-properly-configure-godaddy-dns-settings/feed/</wfw:commentRss> <slash:comments>13</slash:comments> </item> <item><title>Nasty IIS/ASP Querystring Cookie Case Bug</title><link>http://scottelkin.com/programming/nasty-iisasp-querystring-cookie-case-bug/</link> <comments>http://scottelkin.com/programming/nasty-iisasp-querystring-cookie-case-bug/#comments</comments> <pubDate>Fri, 29 Feb 2008 20:53:23 +0000</pubDate> <dc:creator>Scott</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[ASP]]></category> <category><![CDATA[bug]]></category> <category><![CDATA[cookies]]></category> <category><![CDATA[IIS]]></category><guid isPermaLink="false">/archive/2008/02/29/Nasty-IIS_2F00_ASP-Querystring-Cookie-Case-Bug.aspx</guid> <description><![CDATA[I just stumbled on a nasty, nasty ASP bug that took about 7 years for me to see. The problem happens when using cookies and querystrings with the same name. A page on the site reads in a variable from the querystring and sets a cookie with the same name to its value, e.g.: strSrc [...]No related posts.]]></description> <content:encoded><![CDATA[<p>I just stumbled on a nasty, nasty ASP bug that took about 7 years for me to see.</p><p>The problem happens when using cookies and querystrings with the same name. A page on the site reads in a variable from the querystring and sets a cookie with the same name to its value, e.g.:</p><p>strSrc = Request.QueryString(&#8220;A&#8221;)<br /> Response.Cookies(&#8220;A&#8221;) = strSource<br /> Response.Cookies(&#8220;A&#8221;).Expires = Now + (2 * 30)</p><p>However, if the variable name in the query string is different from the capitalization of the cookie name (e.g page.asp?a=xxx) then a new cookie gets set with the name matching the captialization of the<br /> QueryString variable.</p><p>So if you run the page multiple ways, a=123 and A=123, two different cookies are set EVEN THOUGH YOUR CODE SAYS Response.Cookies(&#8220;A&#8221;) = strSource!</p><p>Attempting to read the cookie value back then returns both values. Reading the cookie value via Request.ServerVariables(&#8220;HTTP_COOKIE&#8221;) shows both values.</p><p>If your code is looking for the “A” cookie later on and there are two cookes there, you will only see the “A” one, which may not be the one you want.</p><p>Since I ran into this, I did see other complain about this as far back as 2003: <a href="http://groups.google.com/group/microsoft.public.inetserver.iis.activeserverpages/browse_thread/thread/805b953bc0e3ad01/3ae60f69dcd6120f?lnk=st&amp;q=asp+iis+querystring+cookie+bug#3ae60f69dcd6120f">here</a>, <a href="http://groups.google.com/group/microsoft.public.inetserver.asp.general/browse_thread/thread/872afab97238cf11/2088dbb3f112b609?lnk=st&amp;q=asp+iis+querystring+cookie+bug#2088dbb3f112b609">here</a>, <a href="http://groups.google.com/group/microsoft.public.inetserver.asp.general/browse_thread/thread/872afab97238cf11/706ae11109ee699a?lnk=st&amp;q=asp+iis+querystring+cookie+bug#706ae11109ee699a">here</a>.</p><div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/ASP">ASP</a>, <a rel="tag" href="http://technorati.com/tag/IIS">IIS</a>, <a rel="tag" href="http://technorati.com/tag/programming">programming</a>, <a rel="tag" href="http://technorati.com/tag/cookies">cookies</a>, <a rel="tag" href="http://technorati.com/tag/querystring">querystring</a>, <a rel="tag" href="http://technorati.com/tag/bug">bug</a>, <a rel="tag" href="http://technorati.com/tag/microsoft">microsoft</a></div><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://scottelkin.com/programming/nasty-iisasp-querystring-cookie-case-bug/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>0.0.0.0 Gateway Causing No Internet Access</title><link>http://scottelkin.com/programming/0000-gateway-causing-no-internet-access/</link> <comments>http://scottelkin.com/programming/0000-gateway-causing-no-internet-access/#comments</comments> <pubDate>Wed, 01 Aug 2007 01:41:52 +0000</pubDate> <dc:creator>Scott</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[Windows]]></category><guid isPermaLink="false">/archive/2007/07/31/53717.aspx</guid> <description><![CDATA[Sometime last week, I stopped being able to get access to the internet while at work.  I could get an IP address from DHCP, but couldn’t get any traffic past our firewall/gateway. I thought it was DHCP server, and was ready to buy a new one as it is 5 years old.  But then I [...]No related posts.]]></description> <content:encoded><![CDATA[<p>Sometime last week, I stopped being able to get access to the internet while at work.  I could get an IP address from DHCP, but couldn’t get any traffic past our firewall/gateway.</p><p>I thought it was DHCP server, and was ready to buy a new one as it is 5 years old.  But then I noticed in my ipconfig /all that I had two gateways:  0.0.0.0, and then on the second line, my correct gateway, 192.168.1.1.  I had never seen two gateways listed, and almost scanned right over it.</p><p>I confirmed that no matter if I set the IP manually, or dynamically, I couldn’t get rid of the 0.0.0.0 gateway.</p><p>I called my friend, the who knows all the technical nitty gritty in the TCP world.</p><p>We fired a command prompt and I printed my computer’s current route table by writing “route print”:</p><p><img src="http://scottelkin.com/images/route-print-before.gif" border="0" alt="Route Print Before" /></p><p>You can clearly see the two lines showing 0.0.0.0.  According to him, there should only be one line.  So we deleted them both:</p><p><img src="http://scottelkin.com/images/route-delete.gif" border="0" alt="Route Delete" /></p><p>This left us at:</p><p><img src="http://scottelkin.com/images/route-print-middle.gif" border="0" alt="Route Print Middle" /></p><p>So then we added the correct one back in:</p><p><img src="http://scottelkin.com/images/route-add.gif" border="0" alt="Route Add" /></p><p>I did one more “route print” to make sure it took:</p><p><img src="http://scottelkin.com/images/route-print-after.gif" border="0" alt="Route Print After" /></p><p>And viola, I have internet access!</p><div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/route+table">route+table</a>, <a rel="tag" href="http://technorati.com/tag/0.0.0.0">0.0.0.0</a>, <a rel="tag" href="http://technorati.com/tag/command+prompt">command+prompt</a></div><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://scottelkin.com/programming/0000-gateway-causing-no-internet-access/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Myspace Statistics</title><link>http://scottelkin.com/programming/aspnet-20/myspace-statistics/</link> <comments>http://scottelkin.com/programming/aspnet-20/myspace-statistics/#comments</comments> <pubDate>Sat, 12 May 2007 06:15:44 +0000</pubDate> <dc:creator>Scott</dc:creator> <category><![CDATA[ASP.NET 2.0]]></category> <category><![CDATA[Technology]]></category><guid isPermaLink="false">/archive/2007/05/11/Myspace-Statistics.aspx</guid> <description><![CDATA[I am watching a programming presentation from the Myspace tech team right now. They are going over their stats and was blown away by the numbers (as of April 2007): 185 Million Registered Users 50.2% Female / 49.8% Male Primary Age Demo: 14 &#8211; 34 Over the last 5 months, had between 39 and 45 [...]No related posts.]]></description> <content:encoded><![CDATA[<p>I am watching a programming presentation from the Myspace tech team right now. They are going over their stats and was blown away by the numbers (as of April 2007):</p><p><img style="padding-right:20px;" alt="Myspace" src="http://farm1.static.flickr.com/136/325866918_e9e2dcc45d_m.jpg" align="left" border="0" /></p><ul><li>185 Million Registered Users<li>50.2% Female / 49.8% Male<li>Primary Age Demo: 14 &#8211; 34<li>Over the last 5 months, had between 39 and 45 Billion page views per month.<li>The second biggest site was Yahoo around 35 Billion. MSN, Google, Ebay and Facebook are all way behind with under 15 Billion.<li>350,000 new registrations each day<li>1 Billion total images on the site, 80 Terabytes of space, 150,000 requests per second<li>Millions of new images/day<li>25 Million Songs, 142 Terabytes of space, 250,000 concurrent streams<li>With Videos, 60 Terabytes of storage, 15,000 concurrent streams, 60,000 new videos / day<li>4.5 Million people on site on any one time<li>7 Datacenters<li>6000 web servers<li>650 ad servers<li>250 database servers<li>70,000 megabits per second bandwith (I run over 20 sites, some considered &#8220;large&#8221; and I don&#8217;t go above 2 mb/s</li><li>80% ASP.NET, 20% Coldfusion</li></ul><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://scottelkin.com/programming/aspnet-20/myspace-statistics/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Delete Files Older Than Date Using Batch Files</title><link>http://scottelkin.com/programming/delete-files-older-than-date-using-batch-files/</link> <comments>http://scottelkin.com/programming/delete-files-older-than-date-using-batch-files/#comments</comments> <pubDate>Fri, 13 Apr 2007 21:18:15 +0000</pubDate> <dc:creator>Scott</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[Windows]]></category><guid isPermaLink="false">/archive/2007/04/13/Delete-Files-Older-Than-Date-Using-Batch-Files.aspx</guid> <description><![CDATA[This problem has nagged at me for years.&#160; Here is a batch command to delete files on a Windows 2003 machine. Forfiles -pC:\backup -s -m*.* -d-5 -c "cmd /c del /q @path" This will delete all files in my backup directory older than 5 days. To test it first, use this: Forfiles -pC:\backup -s -m*.* [...]No related posts.]]></description> <content:encoded><![CDATA[<p>This problem has nagged at me for years.&nbsp; Here is a batch command to delete files on a Windows 2003 machine.</p><p><code>Forfiles -pC:\backup -s -m*.* -d-5 -c "cmd /c del /q @path" </code></p><p>This will delete all files in my backup directory older than 5 days. To test it first, use this:</p><p><code>Forfiles -pC:\backup -s -m*.* -d-5 -c "cmd /C Echo 0x22@Path\@File0x22" </code></p><p>This will print out each file that you will be deleting.</p><p><strong>Now playing:</strong> <a href="http://phobos.apple.com/WebObjects/MZSearch.woa/wa/advancedSearchResults?artistTerm=Lamb Of God">Lamb Of God</a> &#8211; <a href="http://phobos.apple.com/WebObjects/MZSearch.woa/wa/advancedSearchResults?songTerm=Terror And Hubris In The House Of Frank Pollard&amp;artistTerm=Lamb Of God">Terror And Hubris In The House Of Frank Pollard</a></p><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://scottelkin.com/programming/delete-files-older-than-date-using-batch-files/feed/</wfw:commentRss> <slash:comments>19</slash:comments> </item> <item><title>Walmart Video Downloads in Firefox</title><link>http://scottelkin.com/programming/css/walmart-video-downloads-in-firefox/</link> <comments>http://scottelkin.com/programming/css/walmart-video-downloads-in-firefox/#comments</comments> <pubDate>Wed, 07 Feb 2007 05:53:06 +0000</pubDate> <dc:creator>Scott</dc:creator> <category><![CDATA[CSS]]></category><guid isPermaLink="false">/archive/2007/02/06/Walmart-Video-Downloads-in-Firefox.aspx</guid> <description><![CDATA[uhhh&#8230;where do I login? No related posts.No related posts.]]></description> <content:encoded><![CDATA[<p>uhhh&hellip;where do I login?</p><p><img alt="Walmart" src="http://scottelkin.com/images/walmart_small.jpg" border="0" /></p><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://scottelkin.com/programming/css/walmart-video-downloads-in-firefox/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Finally, The Truth on OEM Software</title><link>http://scottelkin.com/programming/finally-the-truth-on-oem-software/</link> <comments>http://scottelkin.com/programming/finally-the-truth-on-oem-software/#comments</comments> <pubDate>Tue, 30 Jan 2007 22:38:07 +0000</pubDate> <dc:creator>Scott</dc:creator> <category><![CDATA[Programming]]></category><guid isPermaLink="false">/archive/2007/01/30/Finally_2C00_-The-Truth-on-OEM-Software.aspx</guid> <description><![CDATA[I just read a great&#160;article on OEM software, called Buying OEM versions of Windows Vista: the facts.&#160; I am sure the data here could be extrapolated to any OEM software. The basics with OEM versions of Vista are: You absolutely can&#160;buy OEM versions lawfully. There is no difference between OEM and non-OEM versions (EXCEPT): It [...]No related posts.]]></description> <content:encoded><![CDATA[<p>I just read a great&nbsp;article on OEM software, called <a href="http://arstechnica.com/news.ars/post/20070130-8730.html">Buying OEM versions of Windows Vista: the facts</a>.&nbsp; I am sure the data here could be extrapolated to any OEM software.</p><p>The basics with OEM versions of Vista are:</p><ol><li>You absolutely can&nbsp;buy OEM versions lawfully.</li><li>There is no difference between OEM and non-OEM versions (EXCEPT):</li><li>It is tied to your motherboard: You cannot move it to a new computer 3 years from now or upgrade your motherboard.</li><li>Once you open the OEM package, you can no longer return it.</li></ol><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://scottelkin.com/programming/finally-the-truth-on-oem-software/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <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>0</slash:comments> </item> <item><title>Add Additional Information to Your Exceptions</title><link>http://scottelkin.com/programming/aspnet-20/add-additional-information-to-your-exceptions/</link> <comments>http://scottelkin.com/programming/aspnet-20/add-additional-information-to-your-exceptions/#comments</comments> <pubDate>Wed, 19 Jul 2006 07:37:00 +0000</pubDate> <dc:creator>Scott</dc:creator> <category><![CDATA[ASP.NET 2.0]]></category> <category><![CDATA[C#]]></category> <category><![CDATA[Enterprise Library]]></category> <category><![CDATA[Exceptions]]></category> <category><![CDATA[Programming]]></category><guid isPermaLink="false">/archive/2006/07/19/Add-Additional-Information-to-Your-Exceptions.aspx</guid> <description><![CDATA[When Enterprise Library was called Microsoft Application Blocks, if you wanted to log an Exception, you would write (assuming &#8220;ex&#8221; is an Exception): ExceptionManager.Publish(ex) And if you wanted to log some extended properties you could do something like this: NameValueCollection customerInfo = new NameValueCollection(); customerInfo.Add("name","scott"); customerInfo.Add("email","blah@blah.com"); ExceptionManager.Publish(ex,customerInfo); Now that I am upgrading all legacy code [...]No related posts.]]></description> <content:encoded><![CDATA[<p>When Enterprise Library was called Microsoft Application Blocks, if you wanted to log an Exception, you would write (assuming &#8220;ex&#8221; is an Exception):</p><pre><code>ExceptionManager.Publish(ex)</code></pre><p>And if you wanted to log some extended properties you could do something like this:</p><pre><code>NameValueCollection customerInfo = new NameValueCollection();
customerInfo.Add("name","scott");
customerInfo.Add("email","blah@blah.com");
ExceptionManager.Publish(ex,customerInfo);
</code></pre><p>Now that I am upgrading all legacy code to Enterprise Library 2006 for .NET 2.0, I couldn’t find a way to do this since the only way to log an error is:</p><pre><code>ExceptionPolicy.HandleException(ex, "General Policy");
</code></pre><p>where “General Policy” is the name of the Exception Policy in the config file telling the Block what to do with the exception.</p><p>Looking in the config file, I noticed a formatter template with the following at the tail end of the template attribute, “…Extended Properties: {dictionary({key} &#8211; {value} )}&#8221;.  The formatter template is used to format the exception that is about to be logged somewhere.  Looking through the code for where it loops through this Dictionary, I noticed it accessing an IDictionary of <a href="http://msdn2.microsoft.com/en-us/library/system.exception.data.aspx">Exception.Data</a>.  Exception.Data?  Where did that come from?</p><p>Data is a new .NET framework 2.0 property of the Exception class to allow you to add any user-defined information about the exception.  Nothing more to it:  Just a simple name/value dictionary for your enjoyment.  As if you couldn’t figure it out, my new code would look like:</p><pre><code>ex.Data.Add("name","scott");
ex.Data.Add("email","blah@blah.com");
ExceptionPolicy.HandleException(ex, "General Policy");</code></pre><p>And as long as you use the default formatter, it will log this data at the end of the FormattedException field.</p><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://scottelkin.com/programming/aspnet-20/add-additional-information-to-your-exceptions/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 @ 2010-07-30 03:46:54 -->