<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>.NET Discussion</title>
	<atom:link href="http://dotnetdiscussion.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotnetdiscussion.net</link>
	<description>.NET Issues, Problems, Code Samples, and Fixes</description>
	<lastBuildDate>Mon, 22 Jun 2009 17:58:54 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/fd4a75d19c20c37040a87ca2160fa573?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>.NET Discussion</title>
		<link>http://dotnetdiscussion.net</link>
	</image>
			<item>
		<title>Shameless Plug: Quotidian Word</title>
		<link>http://dotnetdiscussion.net/2009/06/22/shameless-plug-quotidian-word/</link>
		<comments>http://dotnetdiscussion.net/2009/06/22/shameless-plug-quotidian-word/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 17:58:04 +0000</pubDate>
		<dc:creator>Some.Net(Guy)</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[plug]]></category>
		<category><![CDATA[quotidianword]]></category>
		<category><![CDATA[vocabulary]]></category>
		<category><![CDATA[words]]></category>

		<guid isPermaLink="false">http://dotnetdiscussion.net/?p=114</guid>
		<description><![CDATA[The site is now live! Check it out: http://www.quotidianword.com. For those who know me, you know that I am a perfectionist and that I pour every ounce of me into whatever project I&#8217;m in. This site is no exception. It has some very cool technical features as well as simply just being easy, fun, and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=114&subd=dotnetdiscussion&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The site is now live! Check it out: <a href="http://www.quotidianword.com">http://www.quotidianword.com</a>. For those who know me, you know that I am a perfectionist and that I pour every ounce of me into whatever project I&#8217;m in. This site is no exception. It has some very cool technical features as well as simply just being easy, fun, and actually educational if you use it right. My favorite feature is the dynamic signature bar that you can drop in a forum signature:</p>
<p><a href="http://www.quotidianword.com/default.aspx?sig=true"><img src="http://www.quotidianword.com/feeds/sig.aspx" alt="QuotidianWord.com" /></a></p>
<p>You should see that this image will change every day, staying current with the current word. It&#8217;s a cool way to keep your signature fresh and interesting (at least I think so <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) Anyways, I hope you enjoy using the site as much as I do, and as much as I enjoyed making it!</p>
Posted in ASP.NET, Portfolio Tagged: plug, quotidianword, vocabulary, words <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiscussion.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiscussion.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiscussion.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiscussion.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiscussion.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiscussion.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiscussion.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiscussion.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiscussion.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiscussion.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=114&subd=dotnetdiscussion&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiscussion.net/2009/06/22/shameless-plug-quotidian-word/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e2e822d32a7ab3d7f0b7098d03b1d16?s=96&#38;d=identicon&#38;r=X" medium="image">
			<media:title type="html">Some.Net(Guy)</media:title>
		</media:content>

		<media:content url="http://www.quotidianword.com/feeds/sig.aspx" medium="image">
			<media:title type="html">QuotidianWord.com</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery: Awesome</title>
		<link>http://dotnetdiscussion.net/2009/06/12/jquery-awesome/</link>
		<comments>http://dotnetdiscussion.net/2009/06/12/jquery-awesome/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 16:34:22 +0000</pubDate>
		<dc:creator>Some.Net(Guy)</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Visual Studio.NET]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://dotnetdiscussion.net/?p=112</guid>
		<description><![CDATA[Back in the day, I discovered jQuery, but never really did anything with it. I always wanted to learn, but really never had the time. I do now. Let me tell you something:
jQuery is friggin awesome.
Let me preface with the fact that I know little to no JavaScript. I once wrote one function to add [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=112&subd=dotnetdiscussion&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Back in the day, <a href="http://dotnetdiscussion.net/2007/12/11/javascript-jquery-interesting/">I discovered jQuery</a>, but never really did anything with it. I always wanted to learn, but really never had the time. I do now. Let me tell you something:</p>
<p><strong><a href="http://www.jquery.com" target="_blank">jQuery</a> is friggin awesome.</strong></p>
<p>Let me preface with the fact that I know little to no JavaScript. I once wrote one function to add the current date to a textbox in JS and it took me around half the day. However, in that same amount of time about two weeks ago, I was able to nearly completely understand how jQuery works. After a week, I was helping out others with their problems.</p>
<p>Don&#8217;t get me wrong, jQuery can&#8217;t do <em>everything</em>, but it sure can do some powerful stuff. For instance, AJAX is a breeze. For one project I had to make an AJAX call to check to see if someone was posting a comment as someone else while logged in as themselves, so I had to write my AJAX function myself. It took me 53 lines of JS and maybe 3 days to get it working right (along with a TON of research). When I wanted to apply that same function to my new project, I thought I would give jQuery a chance.</p>
<p>Eight lines of code. Actually, technically one line of code because I broke it into several lines: </p>
<p><code>function MakeCall(url,doAsync,callback) {<br />
    $.ajax({<br />
        url: url,<br />
        async: doAsync,<br />
        dataType: "text",<br />
        success: callback<br />
    });<br />
}</code></p>
<p>Of course I have to handle the &#8220;callback&#8221; in the function that&#8217;s calling the MakeCall() function, but the actual making the call has been reduced by 85%. And it&#8217;s easier to maintain and reuse! This isn&#8217;t all that jQuery is good for. I believe jQuery&#8217;s strongest feature is its document manipulation. If you want to change something, all you have to do is select the element or class and, well, change it. For instance, if you have a div with an id of &#8220;myDiv&#8221;, to change the CSS class on it, you just do:</p>
<p><code>$("#myDiv").addClass("someClass");</code></p>
<p>Really, that&#8217;s it. If you wanted to do that when something is clicked, you could do:</p>
<p><code>$("#myLink").click(function () { $("#myDiv").addClass("someClass"); });</code></p>
<p>No, for real. That&#8217;s all you have to do. You can also manipulate things on page load:</p>
<p><code>$.(document).ready( function () { //run functions here });</code></p>
<p>The last and I think one of the most important aspects of jQuery is that it is VERY well documented, VERY ardently followed, and VERY well supported. You can even <a href="http://mwtech.blogspot.com/2009/05/how-to-get-jquery-intellisense-working.html" target="_blank">get Intellisense in Visual Studio 2008</a>! I couldn&#8217;t possibly go through all the cool stuff that jQuery can do. You&#8217;ll have to see for yourself. It truly is amazing, and it is, as I was told, &#8220;brain-dead-stupid easy to learn&#8221;.</p>
Posted in AJAX, CSS, Javascript, jquery, Tips &amp; Tricks, Visual Studio.NET  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiscussion.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiscussion.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiscussion.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiscussion.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiscussion.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiscussion.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiscussion.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiscussion.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiscussion.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiscussion.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=112&subd=dotnetdiscussion&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiscussion.net/2009/06/12/jquery-awesome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e2e822d32a7ab3d7f0b7098d03b1d16?s=96&#38;d=identicon&#38;r=X" medium="image">
			<media:title type="html">Some.Net(Guy)</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio/VB.NET: How To Easily Document Your Code</title>
		<link>http://dotnetdiscussion.net/2009/05/20/visual-studiovb-net-how-to-easily-document-your-code/</link>
		<comments>http://dotnetdiscussion.net/2009/05/20/visual-studiovb-net-how-to-easily-document-your-code/#comments</comments>
		<pubDate>Wed, 20 May 2009 22:36:51 +0000</pubDate>
		<dc:creator>Some.Net(Guy)</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio.NET]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[vs2005]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://dotnetdiscussion.net/?p=105</guid>
		<description><![CDATA[If you&#8217;re a routine Visual Studio user like me, I don&#8217;t need to tell you how awesome Intellisense is. Not only would some of us be lost without it, but it also helps us be way more efficient programmers either through simple selection of methods or properties or by discovering new object members that maybe [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=105&subd=dotnetdiscussion&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>If you&#8217;re a routine Visual Studio user like me, I don&#8217;t need to tell you how awesome Intellisense is. Not only would some of us be lost without it, but it also helps us be way more efficient programmers either through simple selection of methods or properties or by discovering new object members that maybe we didn&#8217;t know about previously. Additionally, one of the main benefits of Intellisense is that it tells you  <em>about</em> the item in question, for instance, that the String.IsNullOrEmpty() function &#8220;Indicates whether the specified System.String object is null or an System.String.Empty string.&#8221;</p>
<p><img class="aligncenter size-full wp-image-106" title="Visual Studio Intellisense" src="http://dotnetdiscussion.files.wordpress.com/2009/05/intellisense.gif?w=451&#038;h=187" alt="Visual Studio Intellisense" width="451" height="187" /></p>
<p>When writing my own objects, however, I used to find myself yearning for this kind of help for my own functions. Wouldn&#8217;t it be great to get Intellisense to tell me what that &#8220;GetUserInfo&#8221; function I wrote five weeks ago does rather than me having to go look it up? What about what those parameter names mean? Luckily, there is a way, and it is super easy.</p>
<p>For example, let&#8217;s say you have an object that returns its own permalink in a shared function called <code>GetHTMLPermaLink()</code>. To document it, simply place your cursor above the function and press the apostrophe key three times: <code>'''</code>. Automagically, the following pops up:</p>
<p><img src="http://dotnetdiscussion.files.wordpress.com/2009/05/documentation.gif?w=452&#038;h=167" alt="Function Documentation" title="Function Documentation" width="452" height="167" class="aligncenter size-full wp-image-109" /></p>
<p>All you have to do is fill in the blanks and viola, you have documented code! (NOTE: in C#, I believe the syntax is <code>///</code> but I&#8217;m not sure.) To see this in action, after you fill in the appropriate information, go try to pull up your function somewhere and watch the magic:</p>
<p style="text-align:center;"><img class="aligncenter size-full wp-image-106" title="Visual Studio Intellisense" src="http://dotnetdiscussion.files.wordpress.com/2009/05/intellisense2.gif" alt="Visual Studio Intellisense" /></p>
<p>More information on <a href="http://aspalliance.com/696_Code_Documentation_in_NET" target="_blank">Visual Studio Code Documentation (C#)</a></p>
<p>Happy documenting!</p>
Posted in Tips &amp; Tricks, VB.NET, Visual Studio.NET Tagged: documentation, vs2005, xml <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiscussion.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiscussion.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiscussion.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiscussion.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiscussion.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiscussion.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiscussion.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiscussion.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiscussion.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiscussion.wordpress.com/105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=105&subd=dotnetdiscussion&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiscussion.net/2009/05/20/visual-studiovb-net-how-to-easily-document-your-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e2e822d32a7ab3d7f0b7098d03b1d16?s=96&#38;d=identicon&#38;r=X" medium="image">
			<media:title type="html">Some.Net(Guy)</media:title>
		</media:content>

		<media:content url="http://dotnetdiscussion.files.wordpress.com/2009/05/intellisense.gif" medium="image">
			<media:title type="html">Visual Studio Intellisense</media:title>
		</media:content>

		<media:content url="http://dotnetdiscussion.files.wordpress.com/2009/05/documentation.gif" medium="image">
			<media:title type="html">Function Documentation</media:title>
		</media:content>

		<media:content url="http://dotnetdiscussion.files.wordpress.com/2009/05/intellisense2.gif" medium="image">
			<media:title type="html">Visual Studio Intellisense</media:title>
		</media:content>
	</item>
		<item>
		<title>My Foray into Regular Expressions with ASP.NET</title>
		<link>http://dotnetdiscussion.net/2009/05/15/my-foray-into-regular-expressions-with-asp-net/</link>
		<comments>http://dotnetdiscussion.net/2009/05/15/my-foray-into-regular-expressions-with-asp-net/#comments</comments>
		<pubDate>Fri, 15 May 2009 18:45:55 +0000</pubDate>
		<dc:creator>Some.Net(Guy)</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio.NET]]></category>

		<guid isPermaLink="false">http://dotnetdiscussion.net/?p=103</guid>
		<description><![CDATA[I know it&#8217;s been a while since I posted here. I&#8217;ve been working pretty diligently on my newest creation, Quotidian Word, which will essentially be a &#8220;word-a-day&#8221; site that encourages users to actually learn the word and use it actively in everyday speech or writing. Right now it&#8217;s only an email harvester so that I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=103&subd=dotnetdiscussion&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I know it&#8217;s been a while since I posted here. I&#8217;ve been working pretty diligently on my newest creation, <a title="Quotidian Word" href="http://www.quotidianword.com" target="_blank">Quotidian Word</a>, which will essentially be a &#8220;word-a-day&#8221; site that encourages users to actually learn the word and use it actively in everyday speech or writing. Right now it&#8217;s only an email harvester so that I can send an email to those interested when it&#8217;s ready, but I&#8217;m nearing the launch point every day <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anyways, the point of this post is to discuss my dip into the world of <a title="Regular Expressions" href="http://en.wikipedia.org/wiki/Regular_expressions" target="_blank">Regular Expressions</a>. I needed to come up with a way to find the word I wanted in a sentence. Easy enough, right? Just <code>mySentence.Contains("myword")</code> and there you go. It would be nice if that&#8217;s all I had to do, but English is a funny language. Every word can assume many forms. For instance, if I want to find the word &#8220;entry&#8221; in a sentence, I also would like to find &#8220;entries&#8221;. Or more simply, if i&#8217;m looking for &#8220;dog&#8221; I also want to find &#8220;dogs&#8221;. Using the <code>mySentence.Contains()</code> method, I would not find &#8220;entries&#8221; and I would find only the &#8220;dog&#8221; in &#8220;dogs&#8221;.</p>
<p>Enter regular expressions.</p>
<p>I had previously shied away from them because when one looks at a regular expression (aka &#8220;regex&#8221;), it can be rather intimidating. Take this stock regular expression that comes with Visual Studio as a default for finding an email address:</p>
<p><code>\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*</code></p>
<p>Your reaction may be the same as mine was: WTF. But when you try to enter an email in a textbox validated by this regex, it knows if you are or not. So my problem was still, how do I find all forms of any word I choose? I took a couple factors into mind, such as, I will mostly be using more obscure words with less common roots, so that will help a bit, and I won&#8217;t be using too many really short words that can be blended into other words in a sentence.</p>
<p>My first thought was ok, how about I first try to find the whole word, then the whole word plus a suffix, then the whole word minus a letter plus a suffix, then a the whole word minus <em>two</em> letters plus a suffix:</p>
<p><code>\bentry\b|((\bentry|\bentr|\bent)(s|es|ies)\b)</code></p>
<p>I used the word &#8220;entry&#8221; as an example here. &#8220;\b&#8221; means either the beginning or the end of a word and &#8220;|&#8221; means &#8220;or&#8221;. The rest is just separated by parens. This worked out ok for a while until I realized that the English language has something like a thousand suffixes. I knew regexes were more powerful than that. There had to be an easier way.</p>
<p>And there was! I was sort of on the right track with the losing of the last two letters. In English, <strong>most</strong> words either simply append a suffix (dog -&gt; dogs), drop one letter and append a suffix (happy -&gt; happiness) or drop two letters and append a suffix (cactus -&gt; cacti). Aside from the word &#8220;person&#8221; (person -&gt; people) I could not think of an instance where a word dropped three or more and would profide me with enough remaining information to actually distinguish it from other words in the sentence. If you can, let me know.</p>
<p>So after a bit more research, and the testing from a handy regex tool called <a href="http://www.ultrapico.com/Expresso.htm" target="_blank">Expresso</a>, my regex eventually evolved into: <code>(?:ent(?:r|ry)?).+?\b</code></p>
<p>Explanation: &#8220;ent&#8221; is what I called the &#8220;root&#8221; of the word, essentially the letters remaining after the last two have been stripped off. &#8220;(?:&#8221; is a grouping that means &#8220;find whatever&#8217;s here, but don&#8217;t actually match it alone&#8221;. This way it doesn&#8217;t find only &#8220;ent&#8221; or &#8220;r&#8221; or &#8220;ry&#8221; and match it, but rather matches the whole thing all together. The clause &#8220;(?:r|ry)?&#8221; means find &#8220;r&#8221; OR &#8220;ry&#8221; (in addition to what comes before it, so &#8220;entr&#8221; or &#8220;entry&#8221;). The &#8220;?&#8221; at the end means the whole clause before it is optional, meaning if it&#8217;s not there, it&#8217;s ok. The &#8220;.+&#8221; means find any character after the previous clause for as many repetitions as you can, so for instance, if the word in the sentence is &#8220;entries&#8221; it will first find the &#8220;ent&#8221; then the &#8220;r&#8221; then any characters that follow &#8220;ies&#8221; up until the end of the word, &#8220;\b&#8221;. The &#8220;?&#8221; at the end of the &#8220;.+&#8221; just means take as few characters as possible up to the next clause, which is the &#8220;\b&#8221;.</p>
<p>Whew! That&#8217;s a lot. I found that this found about 99% of the words that I would be using in all their various forms. But then I got to thinking, what about prefixes? What if someone used something like &#8220;anti&#8221; or &#8220;pre&#8221; or something in front of a word to change it just slightly? Hence, my (nearly) final product:</p>
<p><code>(?:(?:\b\w+)?{1}(?:{2}|{3})?).+?\b</code></p>
<p>where {1} is the word minus the last two letters, {2} is the penultimate letter, and {3} is the last two letters. The optional clause at the beginning takes care of any prefix if it happens to exist.</p>
<p>Great! All done. It can pull it out of a string, no problem. Now if someone enters the word in a sentence in my textbox it will find&#8230;it&#8230; crap. It doesn&#8217;t work as is with the RegexValidator in ASP.NET on textboxes. Why? Because the validator is looking at the <em>whole string</em> in the textbox to see if it fits the regular expression. For instance, the email regular expression assumes that whatever you enter into that textbox is going to be an email, nothing else. If you enter a sentence into a textbox, it assumes that whatever you enter into that textbox is going to fit the regex.</p>
<p>In order to counter this problem, I put in a simple fix: I prepended and appended my regex for textboxes with &#8220;.*&#8221;, which means that it will find any characters before or after the word we&#8217;re looking for. Done! &#8230; Right?</p>
<p>So I thought, until I realized that when people enter sentences, usually they do so in multiline textboxes, as they&#8217;re easier to see everything you&#8217;re doing. This regex works until the user hits the &#8220;Enter&#8221; key and inserts a new line. After much research and hair pulling, I eventually found the solution:</p>
<p><code>^(.|\r|\n)*(?:(?:\b\w+)?{1}(?:{2}|{3})?).+?\b(.|\r|\n)*$</code></p>
<p>with {1},{2}, and {3} meaning the same thing. The interesting thing about the &#8220;.&#8221; character in regexes is it means &#8220;match any character&#8230;..except new lines and carriage returns&#8221;, which means if you&#8217;re using multiline textboxes, you have to account for that. So I had to prepend &#8220;^(.|\r|\n)*&#8221; and append &#8220;(.|\r|\n)*$&#8221; to my already unwieldy regex. &#8220;\r&#8221; is a carriage return and &#8220;\n&#8221; is a new line. The &#8220;^&#8221; symbol means start at the beginning of the string, and the &#8220;$&#8221; means continue to the end of the string, with the &#8220;*&#8221; symbols meaning repeat as often as necessary.</p>
<p>To finalize the product, I simply plugged all of this information into a shared function that returns the proper regex (based on a parameter that determines if I&#8217;m using it on a regular string, a textbox, or a multiline textbox) and set my validator&#8217;s ValidationExpression at runtime based on the word I was looking for. It actually works pretty well&#8230; so far&#8230;. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>All in all, I think I like regexes. They are undoubtedly powerful and can save many programming hours if you know how to use them. I know the initial function I was using to find words in a sentence took me maybe two hours to write and it didn&#8217;t even work all the time. It was also about 200ish lines of code. My new function using regexes is 17 lines of actual code, and 7 of that is a Select statement for string/textbox/multiline textbox.</p>
<p>While the initial learning curve is quite steep for regexes, if you&#8217;re serious about programming, I highly suggest that you take a day or two to learn them, as that day or two investment could save you weeks or months down the line of your programming career.</p>
<p>Some regex resources:</p>
<ul>
<li><a href="http://www.regular-expressions.info">www.regular-expressions.info</a></li>
<li><a href="http://gnosis.cx/publish/programming/regular_expressions.html">http://gnosis.cx/publish/programming/regular_expressions.html</a></li>
<li><a href="http://www.silverstones.com/thebat/Regex.html">http://www.silverstones.com/thebat/Regex.html</a></li>
<li><a href="http://www.codeproject.com/KB/dotnet/regextutorial.aspx">http://www.codeproject.com/KB/dotnet/regextutorial.aspx</a></li>
</ul>
<p><strong>What&#8217;s your craziest regex?</strong></p>
Posted in ASP.NET, Javascript, Regex, VB.NET, Visual Studio.NET  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiscussion.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiscussion.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiscussion.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiscussion.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiscussion.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiscussion.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiscussion.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiscussion.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiscussion.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiscussion.wordpress.com/103/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=103&subd=dotnetdiscussion&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiscussion.net/2009/05/15/my-foray-into-regular-expressions-with-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e2e822d32a7ab3d7f0b7098d03b1d16?s=96&#38;d=identicon&#38;r=X" medium="image">
			<media:title type="html">Some.Net(Guy)</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET: Create a User Control Property with Selectable Options</title>
		<link>http://dotnetdiscussion.net/2009/02/05/aspnet-create-a-user-control-property-with-selectable-options/</link>
		<comments>http://dotnetdiscussion.net/2009/02/05/aspnet-create-a-user-control-property-with-selectable-options/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 16:04:42 +0000</pubDate>
		<dc:creator>Some.Net(Guy)</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio.NET]]></category>

		<guid isPermaLink="false">http://dotnetdiscussion.net/?p=94</guid>
		<description><![CDATA[I guess I&#8217;ve always taken those little options for granted whenever I want to pick something in a control, say what mode to put a textbox in (text, multiline, or password), because when I wanted to add something similar for a user control, I had no idea how to do it. Thanks to the friendly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=94&subd=dotnetdiscussion&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I guess I&#8217;ve always taken those little options for granted whenever I want to pick something in a control, say what mode to put a textbox in (text, multiline, or password), because when I wanted to add something similar for a user control, I had no idea how to do it. Thanks to the friendly and extremely helpful people at <a title="Stack Overflow" href="http://stackoverflow.com" target="_blank">StackOverflow</a>, I was able to grok the answer.</p>
<p><img class="aligncenter size-full wp-image-95" title="Intellisense options" src="http://dotnetdiscussion.files.wordpress.com/2009/02/options.jpg?w=305&#038;h=96" alt="Intellisense options" width="305" height="96" /></p>
<p>Here&#8217;s the scenario: you have a user control in your .aspx page with one property, say &#8220;addedorapproved&#8221; as in the above image. You want the options &#8220;Added&#8221; and &#8220;Approved&#8221; to show up as your selectable options. To do so, you must complete the following steps:</p>
<ol>
<li>Create an enum with your available options:<br />
<span style="color:#0000ff;">Enum </span>AddApproveOptions<br />
Added<br />
Approved<br />
<span style="color:#0000ff;">End Enum</span></li>
<li>Create your private member as your Enum:<br />
<span style="color:#0000ff;">Private</span> _addedapproved <span style="color:#0000ff;">As</span> AddApproveOptions</li>
<li>Create your property as your Enum:<br />
<span style="color:#0000ff;">Public Property</span> AddedOrApproved() <span style="color:#0000ff;">As</span> AddApproveOptions<br />
<span style="color:#0000ff;">Get</span><br />
<span style="color:#0000ff;">Return</span> _addedapproved<br />
<span style="color:#0000ff;">End Get<br />
</span><span style="color:#0000ff;">Set</span>(<span style="color:#0000ff;">ByVal</span> value <span style="color:#0000ff;">As</span> AddApproveOptions)<br />
_addedapproved = value<br />
<span style="color:#0000ff;">End Set<br />
End Property</span></li>
</ol>
<p> And that&#8217;s it! You should see the little Intellisense box pop up with your options for your new property!</p>
Posted in ASP.NET, Tips &amp; Tricks, VB.NET, Visual Studio.NET  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiscussion.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiscussion.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiscussion.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiscussion.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiscussion.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiscussion.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiscussion.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiscussion.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiscussion.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiscussion.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=94&subd=dotnetdiscussion&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiscussion.net/2009/02/05/aspnet-create-a-user-control-property-with-selectable-options/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e2e822d32a7ab3d7f0b7098d03b1d16?s=96&#38;d=identicon&#38;r=X" medium="image">
			<media:title type="html">Some.Net(Guy)</media:title>
		</media:content>

		<media:content url="http://dotnetdiscussion.files.wordpress.com/2009/02/options.jpg" medium="image">
			<media:title type="html">Intellisense options</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Search Funny</title>
		<link>http://dotnetdiscussion.net/2008/12/03/google-search-funny/</link>
		<comments>http://dotnetdiscussion.net/2008/12/03/google-search-funny/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 15:43:15 +0000</pubDate>
		<dc:creator>Some.Net(Guy)</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://dotnetdiscussion.wordpress.com/?p=86</guid>
		<description><![CDATA[Although a bit unrelated to .NET, this was too funny not to share:
Every morning, I go through my www.columbussupply.com logs to see how products are doing, which are being visited, and where people come from to see how we&#8217;re placed and what other products show up. One such referral URL caught my eye: http://www.google.com/search?q=Deluxe+Model+Inflatable+Woman&#38;ie=utf-8&#38;oe=utf-8&#38;aq=t&#38;rls=org.mozilla:en-US:official&#38;client=firefox-a
Which results [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=86&subd=dotnetdiscussion&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Although a bit unrelated to .NET, this was too funny not to share:</p>
<p>Every morning, I go through my <a href="http://www.columbussupply.com">www.columbussupply.com</a> logs to see how products are doing, which are being visited, and where people come from to see how we&#8217;re placed and what other products show up. One such referral URL caught my eye: <a href="http://www.google.com/search?q=Deluxe+Model+Inflatable+Woman&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a">http://www.google.com/search?q=Deluxe+Model+Inflatable+Woman&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a</a></p>
<p>Which results in this (Note: I moved the results count to the left in photoshop to keep the image smaller):</p>
<p><a href="http://dotnetdiscussion.files.wordpress.com/2008/12/ss1.jpg"><img class="size-full wp-image-89 alignnone" title="Google Screen Shot" src="http://dotnetdiscussion.files.wordpress.com/2008/12/ss1.jpg?w=539&#038;h=203" alt="Google Screen Shot" width="539" height="203" /></a></p>
<p style="text-align:center;">
<p>Yes, that is someone searching for a blowup doll and found my site. As the first result in Google. At 6am. Hey, traffic is traffic, right?</p>
Posted in Google, Random  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiscussion.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiscussion.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiscussion.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiscussion.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiscussion.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiscussion.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiscussion.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiscussion.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiscussion.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiscussion.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=86&subd=dotnetdiscussion&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiscussion.net/2008/12/03/google-search-funny/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e2e822d32a7ab3d7f0b7098d03b1d16?s=96&#38;d=identicon&#38;r=X" medium="image">
			<media:title type="html">Some.Net(Guy)</media:title>
		</media:content>

		<media:content url="http://dotnetdiscussion.files.wordpress.com/2008/12/ss1.jpg" medium="image">
			<media:title type="html">Google Screen Shot</media:title>
		</media:content>
	</item>
		<item>
		<title>Advertising Update</title>
		<link>http://dotnetdiscussion.net/2008/11/10/advertising-update/</link>
		<comments>http://dotnetdiscussion.net/2008/11/10/advertising-update/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 14:29:25 +0000</pubDate>
		<dc:creator>Some.Net(Guy)</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[Adsense]]></category>
		<category><![CDATA[Advertising]]></category>

		<guid isPermaLink="false">http://dotnetdiscussion.wordpress.com/?p=80</guid>
		<description><![CDATA[After speaking some more with the &#8221;powers that be&#8221; I decided to go forth with the ad units. You can find them on any product page at www.columbussupply.com. I tried to blend the ads into the theme of the site without hiding them entirely. The purpose of the ads is still for them to be clicked, but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=80&subd=dotnetdiscussion&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>After speaking some more with the &#8221;powers that be&#8221; I decided to go forth with the ad units. You can find them on any product page at <a href="http://www.columbussupply.com">www.columbussupply.com</a>. I tried to blend the ads into the theme of the site without hiding them entirely. The purpose of the ads is still for them to be clicked, but not to overpower the message of the product description, as the purpose of the product description is still to sell the product. Essentially, we&#8217;re trying to monetize the casual browser who is not really intending to buy anything but is rather looking around or comparison shopping. Those who are looking to buy something will buy something, ad click or not, since we really (actually) do have the best prices on the internet for virtually everything we sell.</p>
<p>I&#8217;m not new to adsense or the placement of ads. I am aware that the placement of the ad is not optimal for the best clickthroughs, but that&#8217;s not the point. I don&#8217;t want my customers to see an ad as the first thing on the page, but rather as they work their way down and have already been served the product description message. The primary goal is to sell products, and I feel that some people may get turned off if they are bombarded with ads as soon as they hit the page.</p>
<p>I&#8217;m interested to hear feedback on how the ads are placed, if they&#8217;re too overbearing, too obvious, not obvious enough, whatever. Do the ads serve their purpose?</p>
Posted in Random Tagged: Adsense, Advertising <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiscussion.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiscussion.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiscussion.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiscussion.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiscussion.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiscussion.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiscussion.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiscussion.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiscussion.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiscussion.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=80&subd=dotnetdiscussion&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiscussion.net/2008/11/10/advertising-update/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e2e822d32a7ab3d7f0b7098d03b1d16?s=96&#38;d=identicon&#38;r=X" medium="image">
			<media:title type="html">Some.Net(Guy)</media:title>
		</media:content>
	</item>
		<item>
		<title>To Advertise or Not To Advertise?</title>
		<link>http://dotnetdiscussion.net/2008/10/16/to-advertise-or-not-to-advertise/</link>
		<comments>http://dotnetdiscussion.net/2008/10/16/to-advertise-or-not-to-advertise/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 20:40:48 +0000</pubDate>
		<dc:creator>Some.Net(Guy)</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[Adsense]]></category>
		<category><![CDATA[Advertising]]></category>

		<guid isPermaLink="false">http://dotnetdiscussion.wordpress.com/?p=77</guid>
		<description><![CDATA[&#8230;that is indeed a troubling question for me and my ecommerce site. Many (if not most) sites on the intartrons leverage Google Adsense to drum up additional funds, and some make a decent profit from it. Up to this point I&#8217;ve resisted placing ads on the Columbus Supply website out of my desire to maintain [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=77&subd=dotnetdiscussion&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>&#8230;that is indeed a troubling question for me and my ecommerce site. Many (if not most) sites on the intartrons leverage Google Adsense to drum up additional funds, and some make a decent profit from it. Up to this point I&#8217;ve resisted placing ads on the <a title="Columbus Supply" href="http://www.columbussupply.com" target="_blank">Columbus Supply</a> website out of my desire to maintain a professional image for the company. We do not *need* the extra funds since we generate plenty from sales. However, we&#8217;ve started (not even started, have been) receiving some significant traffic for some time now and I can&#8217;t help but think how great it would be to supplement our company income with a bit of ad revenue.</p>
<p>I did a bit of research and discovered sites like amazon.com, woot.com, and buy.com do, in fact, have advertising spots in various locations throughout their site. These are pretty big sites that can be considered somewhat similar to ours. I also noticed that sites like newegg.com, grainger.com, and edarley.com do not have any advertising spots. I have admittedly tried to model a lot of our business off NewEgg&#8217;s, since I like the way they do things.</p>
<p>What are your thoughts on adding theme-matching, unobtrusive, responsibly-placed advertisements on the site? Would it ruin the &#8220;classiness&#8221; or &#8220;professionalism&#8221; of the site? Would it detract from the items and cause a possible dip in sales? Or do you think that it will provide a non-threatening way to cash in off the casual browser who does not necessarily intend to purchase from us?</p>
Posted in Random Tagged: Adsense, Advertising <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiscussion.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiscussion.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiscussion.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiscussion.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiscussion.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiscussion.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiscussion.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiscussion.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiscussion.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiscussion.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=77&subd=dotnetdiscussion&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiscussion.net/2008/10/16/to-advertise-or-not-to-advertise/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e2e822d32a7ab3d7f0b7098d03b1d16?s=96&#38;d=identicon&#38;r=X" medium="image">
			<media:title type="html">Some.Net(Guy)</media:title>
		</media:content>
	</item>
		<item>
		<title>BlogEngine.NET: How To Customize Your Blog With New Class Objects</title>
		<link>http://dotnetdiscussion.net/2008/09/30/blogenginenet-how-to-customize-your-blog-with-new-class-objects/</link>
		<comments>http://dotnetdiscussion.net/2008/09/30/blogenginenet-how-to-customize-your-blog-with-new-class-objects/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 20:28:04 +0000</pubDate>
		<dc:creator>Some.Net(Guy)</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[BlogEngine.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Visual Studio.NET]]></category>
		<category><![CDATA[BlogEngine.Core]]></category>
		<category><![CDATA[BlogProvider]]></category>
		<category><![CDATA[BlogService]]></category>
		<category><![CDATA[BusinessBase]]></category>
		<category><![CDATA[DbBlogProvider]]></category>

		<guid isPermaLink="false">http://dotnetdiscussion.wordpress.com/?p=73</guid>
		<description><![CDATA[I&#8217;ve been working pretty extensively with BlogEngine.NET over the past few months and have learned a lot about its inner workings. My project (www.madcowultimate.com) has essentially used the BlogEngine.NET platform (connected to a MySQL database) as a base to create a full-fledged website. Of course, all of the customization I&#8217;ve done to the core would mean [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=73&subd=dotnetdiscussion&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve been working pretty extensively with <a title="BlogEngine.NET" href="http://www.dotnetblogengine.net" target="_blank">BlogEngine.NET</a> over the past few months and have learned a lot about its inner workings. My project (<a href="http://www.madcowultimate.com">www.madcowultimate.com</a>) has essentially used the BlogEngine.NET platform (connected to a MySQL database) as a base to create a full-fledged website. Of course, all of the customization I&#8217;ve done to the core would mean that I am stuck with this version (1.4.5.0) of the platform, but so far I am okay with that. It serves my purposes for the most part, and everything else I can make work to fit my needs.</p>
<p>One of the major parts of customizing the core to shape the BE.NET platform into your custom solution is creating your own business classes. For instance, in my site, I needed a way for my teammates to check the status of practice, since some of them come in from out of town and would probably prefer to know if practice is on or off for that day before driving in. Thus, I created the Practice class in the BlogEngine.Core namespace to populate a widget displaying the status.</p>
<p>How did I do this? Well, I wish it was as easy as 1, 2, 3, but this project is a little more complex than that. I have definitely learned a lot by wading through the code, but I have also made some mistakes and wasted some time trying things out that did not work. I will break it down for you into manageable chunks, but you will still need to know certain things, like SQL (or MySQL), data table architecture, how classes and objects fundamentally work, and a little bit about inheritance and abstraction.</p>
<p>The following will assume that you have successfully created your blog on your webserver and that you are hooked up to a database (I will use MySQL in this example). I would highly recommend you back up your entire project before embarking on any changes that may affect your blog (especially changes to the core).</p>
<p>First things first, open BE.NET in Visual Studios and expand BlogEngine.Core. You should see a list of familiar-looking classes like Post.cs, Page.cs, and Category.cs. To create your own class, you will essentially need to model your class after these. Right-click on BlogEngine.Core and go to Add &gt; Class&#8230; and type the name for your new class. For the purposes of this article, we&#8217;ll call it <strong>MyObject.cs</strong>.</p>
<p>At the top where you import classes, you will need to add at least &#8220;<span style="color:#0000ff;">using</span> BlogEngine.Core.Providers&#8221;, in addition to any other classes you will need (you can, of course, add any you need later). This will make it easier to hook your object up to the data provider. Next, put your object in the &#8220;BlogEngine.Core&#8221; namespace and have your object inherit the BusinessBase, like so:</p>
<pre name="code" class="c#">
namespace BlogEngine.Core
{
    public class MyObject: BusinessBase&lt;myobject , int&gt;
    {
    }
}
</pre>
<p>Inheriting the BusinessBase will do a lot of your work for you when it comes to managing your object, like knowing which properties have been changed and saving your data. Next you&#8217;ll want to create your constructor. You won&#8217;t use this very frequently (more on that later), but you still need to have it:</p>
<pre name="code" class="c#">
public MyObject(int id)
{
    base.Id = id;
}
</pre>
<p>After this, create whatever properties you need using the following template:</p>
<pre name="code" class="c#">
private bool _myproperty;
public bool MyProperty
{
    get { return _myproperty; }
    set
    {
        if (value != _myproperty) MarkChanged(&quot;MyProperty&quot;);
        _myproperty= value;
    }
}
</pre>
<p>This alerts the BusinessBase when something has been changed so that it may take the appropriate action when you need to save your data.  You can (and should) also create a read-only ID property by just returning the base ID:</p>
<pre name="code" class="c#">
public int MyObjectID
{
    get { return Id; }
}
</pre>
<p>Of course you may create your own methods if you would like, but they are not required. The last step in your basic class construction is to override the base methods for data retrieval/storage/deletion. These are abstract methods delineated by the BusinessBase you inherited, so they are required by your class.  When you are done, they should look like this:</p>
<pre name="code" class="c#">
protected override void ValidationRules()
{
    //nothing
}

protected override MyObject DataSelect(int id)
{
    return BlogService.SelectMyObject(id);
}

protected override void DataUpdate()
{
    BlogService.UpdateMyObject(this);
}

protected override void DataInsert()
{
    if (IsNew)
    BlogService.InsertMyObject(this);
}

protected override void DataDelete()
{
    BlogService.DeleteMyObject(this);
}
</pre>
<p>You may have noticed at this point that your Intellisense isn&#8217;t coming up with the methods &#8220;SelectMyObject&#8221; or &#8220;UpdateMyObject&#8221; when you type in BlogService. This is because we need to add them to your BlogService class. This class is created to separate data access and business so any kind of data provider can be used without any change to how the class functions, therefore making it extremely flexible.</p>
<p>Before you modify your BlogService.cs class, you will need to add the abstract methods to your <strong>BlogProvider.cs </strong>class, which is in the &#8220;Providers&#8221; folder. This is where you create the outline for the methods you just outlined in your class. You probably can do this before the last step in your class construction (so that Intellisense will show up, thereby preventing any typos) but it&#8217;s not necessary so long as you&#8217;re keeping track of what you&#8217;re doing. Go ahead and add the following somewhere in that class file:</p>
<pre name="code" class="c#">
public abstract MyObject SelectMyObject(int id);
public abstract void InsertMyObject(MyObject obj);
public abstract void UpdateMyObject(MyObject obj);
public abstract void DeleteMyObject(MyObject obj);
</pre>
<p>This will create the framework for data access to your object that will be inherited by the respective providers.</p>
<p>Now go ahead and open your <strong>BlogService.cs </strong>class located in the &#8220;Providers&#8221; folder. Don&#8217;t worry too much about what is going on here, just know that a lot of work has been done on your behalf so that it is this simple (two lines of code!) to hook up your object to your data provider of choice per action required by your object. If you really want to look, expand the region in this file called &#8220;Provider Model&#8221; and look at the details. When you&#8217;re done adding your static methods for your object, it should look something like this:</p>
<pre name="code" class="c#">
public static MyObject SelectMyObject(int id)
{
    LoadProviders();
    return _provider.SelectMyObject(id);
}

public static void InsertMyObject(MyObject obj)
{
    LoadProviders();
    _provider.InsertMyObject(obj);
}

public static void UpdateMyObject(MyObject obj)
{
    LoadProviders();
    _provider.UpdateMyObject(obj);
}
public static void DeleteMyObject(MyObject obj)
{
    LoadProviders();
    _provider.DeleteMyObject(obj);
}
</pre>
<p>Finally, once all your structures are completed, you&#8217;ll need to add the actual functionality to your data access. This is done in the <strong>DbBlogProvider.cs</strong> file, also located in the &#8220;Providers&#8221; folder. As you will see, because this class inherits the BlogProvider class, it is mandatory that it include (and provide the behavior for) the methods you just described in the BlogProvider.cs. This becomes most obvious when you start typing your methods and Intellisense finishes the rest of your method signature.</p>
<p>This is the point at which you should start creating your data tables that are going to be accessed and modified by your blog, as you will need to know what tables to access and what fields to call in your SQL string!</p>
<p>After you have created your tables, you should go back to the DbBlogProvider file and create a region for your object&#8217;s data access methods and start filling them in with the appropriate SQL. Since I don&#8217;t know what your objects requirements are, I can&#8217;t really help you any further than this, other than to tell you to take a look at how other objects&#8217; data is being accessed for the same behavior (for example, look at how a post is selected, inserted, updated, and deleted) and model yours off of theirs. This part probably takes the longest, since you need to know what to get and how to get it, but if you follow the other objects&#8217; examples, you&#8217;ll see that you can benefit from a lot of copy and paste action.</p>
<p>After you complete all of your data access functions, you&#8217;re pretty much done! Now, how do you get an instance of the object you just built? Not in the typical manner, which would be to use the &#8220;new&#8221; keyword, but rather using the BusinessBase&#8217;s static .Load() function, or MyObject.Load(id);. Of course, once you&#8217;re done modifying the core, don&#8217;t forget to build it (right-click on BlogEngine.Core &gt; Build)! If you get any errors, be sure to fix them, as your project will not work until the Core can compile.</p>
<p>I&#8217;m somewhat certain this covers the basic complexity involved in the creation of a new, custom object. I hope this saves someone some time! I wish I had known this before going into this project, as I know it would have saved me a lot of time and figuring out. Good luck, and let me know if I forgot anything, as I will gladly add it.</p>
<p><a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnetdiscussion.net%2f2008%2f09%2f30%2fblogenginenet-how-to-customize-your-blog-with-new-class-objects%2f"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnetdiscussion.net%2f2008%2f09%2f30%2fblogenginenet-how-to-customize-your-blog-with-new-class-objects%2f&amp;border=ffffff&amp;fgcolor=555555&amp;bgcolor=bec3c1&amp;cfgcolor=226699&amp;cbgcolor=e7c68c" border="0" alt="kick it on DotNetKicks.com" /></a></myobject></p>
Posted in ASP.NET, BlogEngine.NET, C#, MySQL, Tips &amp; Tricks, Visual Studio.NET Tagged: BlogEngine.Core, BlogProvider, BlogService, BusinessBase, DbBlogProvider <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiscussion.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiscussion.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiscussion.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiscussion.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiscussion.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiscussion.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiscussion.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiscussion.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiscussion.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiscussion.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=73&subd=dotnetdiscussion&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiscussion.net/2008/09/30/blogenginenet-how-to-customize-your-blog-with-new-class-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e2e822d32a7ab3d7f0b7098d03b1d16?s=96&#38;d=identicon&#38;r=X" medium="image">
			<media:title type="html">Some.Net(Guy)</media:title>
		</media:content>

		<media:content url="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnetdiscussion.net%2f2008%2f09%2f30%2fblogenginenet-how-to-customize-your-blog-with-new-class-objects%2f&#38;border=ffffff&#38;fgcolor=555555&#38;bgcolor=bec3c1&#38;cfgcolor=226699&#38;cbgcolor=e7c68c" medium="image">
			<media:title type="html">kick it on DotNetKicks.com</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Chrome: First Bug</title>
		<link>http://dotnetdiscussion.net/2008/09/10/google-chrome-first-bug/</link>
		<comments>http://dotnetdiscussion.net/2008/09/10/google-chrome-first-bug/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 15:58:01 +0000</pubDate>
		<dc:creator>Some.Net(Guy)</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[IE7]]></category>

		<guid isPermaLink="false">http://dotnetdiscussion.wordpress.com/?p=68</guid>
		<description><![CDATA[I like to be an early adopter of new technologies, so when Google Chrome came out, naturally I downloaded it.  There are many features I liked, including the quickness of loading and the ability to turn my Gmail into an application.  However, there are still some problems that need to be ironed out, and until [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=68&subd=dotnetdiscussion&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I like to be an early adopter of new technologies, so when <a title="Google Chrome" href="http://www.google.com/chrome" target="_blank">Google Chrome</a> came out, naturally I downloaded it.  There are many features I liked, including the quickness of loading and the ability to turn my Gmail into an application.  However, there are still some problems that need to be ironed out, and until they do, I will not be using this browser for anything at all, save development (yeah, thanks for another browser to check. Ugh).</p>
<p>First of all, Google Chrome isn&#8217;t actually a new rendering browser; <a title="Google Chrome" href="http://www.coderjournal.com/2008/09/google-chrome/" target="_blank">it&#8217;s essentially Apple Safari re-branded</a>. So if your pages work in Safari, typically they&#8217;ll work in Chrome. But I don&#8217;t use Safari, and now I know that if ever given the chance I wouldn&#8217;t. The way it handles things is so dumb compared to IE7. For instance, if I want to add a link in Gmail using IE7, I highlight the text I want to link, click the link button, enter my link, and hit enter, and the highlighted text is now a link.  In Chrome, I follow the same steps, except when I&#8217;m done, there&#8217;s an additional space after the word. At this point, you&#8217;re thinking, you nitpicky a-hole, but the problem with this is, let&#8217;s say I want to put a comma next to the linked text. If I try to do that (which I do whenever I process an order), Chrome assumes the comma is part of the link, and then any text following the comma that I type becomes the link. Now if I only linked to things in emails every once in a while, I could live with it, but this is something I do 20-30 times a day. It gets annoying.</p>
<p>There are a plethora of other weird (and admittedly nitpicky) differences. For instance, when holding Ctl and pressing an arrow key to highlight a word, it selects the word and the preceding space. Or when copying and pasting something with formatting, some of the formatting is stripped, some is kept, with no rhyme or reason as to what. Also try pasting anything copied from Excel. Gross.</p>
<p>While yes, these annoyances are small, remember that if I&#8217;m going to start using a new browser over one that I&#8217;m already comfortable with, it has to provide me with features the incumbent does not without pushing me out of my comfort zone. Even still, due to sheer geekdom and willingness to be on the &#8220;cutting edge&#8221;, I endured these minor hardships.</p>
<p>Until I started receiving reply emails from people wondering who the hell I was.</p>
<p>I have several email addresses that forward to my main (hub) Gmail account, and I have them set up as &#8220;Accounts&#8221; within Gmail so that I may send as that email address. I use this feature very frequently, as I like to keep certain emails separate during certain parts of the order lifecycle (ordering, processing, shipping, support, etc). However, I also run several other websites on which I have email accounts that I run into my Gmail account. In IE7, I choose which address I want to send out as and it works, no problem. In Chrome, I pick the one I want to send as, and it picks whichever one it wants, often resulting in a very incorrect FROM address.  Unfortunately, this is a dealbreaker.</p>
<p>So until Google Chrome undergoes some signficant changes (the last one being the most important), I will not be using this browser outside of the development arena (again, thanks for giving me another browser to check, Google).</p>
<p>Has anyone else experienced any other bugs in Chrome? Maybe in certain apps/sites?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotnetdiscussion.wordpress.com/68/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotnetdiscussion.wordpress.com/68/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiscussion.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiscussion.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiscussion.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiscussion.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiscussion.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiscussion.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiscussion.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiscussion.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiscussion.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiscussion.wordpress.com/68/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiscussion.net&blog=1333069&post=68&subd=dotnetdiscussion&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiscussion.net/2008/09/10/google-chrome-first-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e2e822d32a7ab3d7f0b7098d03b1d16?s=96&#38;d=identicon&#38;r=X" medium="image">
			<media:title type="html">Some.Net(Guy)</media:title>
		</media:content>
	</item>
	</channel>
</rss>