<?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>The Dev Shack &#187; .NET</title>
	<atom:link href="http://www.thedevshack.com/category/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thedevshack.com</link>
	<description>Technology and Programming Blog</description>
	<lastBuildDate>Mon, 06 Jun 2011 00:13:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Post #2: Use the .NET TweetSharp Library to Integrate with Twitter via OAuth</title>
		<link>http://www.thedevshack.com/post-2-use-the-net-tweetsharp-library-to-integrate-with-twitter-via-oauth/</link>
		<comments>http://www.thedevshack.com/post-2-use-the-net-tweetsharp-library-to-integrate-with-twitter-via-oauth/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 12:42:55 +0000</pubDate>
		<dc:creator>mfleming</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.thedevshack.com/?p=350</guid>
		<description><![CDATA[Today&#8217;s post is the second in a series explaining how to integrate TweetSharp into your .NET application using OAuth.&#160; In our first post we covered the basics of registering a new application with Twitter.&#160; This post will cover how you ask, then grant access from someone&#8217;s Twitter account to your new application using OAuth. We [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s post is the second in a series explaining how to integrate TweetSharp into your .NET application using OAuth.&nbsp; In our first post we covered the basics of registering a new application with Twitter.&nbsp; This post will cover how you ask, then grant access from someone&#8217;s Twitter account to your new application using OAuth.<span id="more-350"></span></p>
<p>We will start by creating a very simple page in our application with a single button.&nbsp; When clicked the button will begin the OAuth process via Twitter.&nbsp; Essentially, the user will tell us they would like to grant acesss to their account from our application.&nbsp; From there we will take their request, send the request to Twitter, then grab the response.</p>
<p>So our first step is to create a way for the user to let us know they would like to use our app.&nbsp; As stated above, this will just be a simple button they user will click to start the process.</p>
<p><code lang="csharp[lines]"><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>       </p>
<p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">       </p>
<p><html xmlns="http://www.w3.org/1999/xhtml"><br />
<head runat="server">       </p>
<p></head><br />
<body>       </p>
<form id="form1" runat="server">
<div>
            <strong>Clicking the button below will start the OAuth process, which will grant our application access to your Twitter account.</strong></p>
<p>            <asp:Button ID="oauthButton" runat="server" Text="Grant Access" OnClick="Oauth_Click" />
        </div>
</p></form>
<p></body><br />
</html></code></p>
<p>In our code behind we will start our process in the function tied to our button.&nbsp; You will notice that I have set some variables that hold some of the values we set up in the first post.&nbsp; When you registered your new application with Twitter they set us up a Consumer Key and a Consumer Secret.&nbsp; We will use these as part of the request we pass back to Twitter.&nbsp; So make sure you replace the variables below with the values from your application.&nbsp; We have tied our click event to a function named Oauth_Click.&nbsp; This function starts our OAuth process.&nbsp; We first set up our request, then pass our user to Twitter.</p>
<p><code lang="csharp[lines]">using System;<br />
using Dimebrain.TweetSharp.Extensions;<br />
using Dimebrain.TweetSharp.Fluent;<br />
using Dimebrain.TweetSharp.Model;     </p>
<p>public partial class _Default : System.Web.UI.Page<br />
{<br />
    private string _consumerKey = "YourKey";<br />
    private string _consumerSecret = "YourSecret";     </p>
<p>    protected void Page_Load(object sender, EventArgs e)<br />
    {     </p>
<p>    }     </p>
<p>    protected void Oauth_Click(Object sender, EventArgs e)<br />
    {<br />
        var request = GetRequestToken();     </p>
<p>        var authorizeUrl = FluentTwitter.CreateRequest()<br />
            .Authentication<br />
            .GetAuthorizationUrl(request.Token);     </p>
<p>        Response.Redirect(authorizeUrl);<br />
    }     </p>
<p>    private OAuthToken GetRequestToken()<br />
    {<br />
        var requestToken = FluentTwitter.CreateRequest()<br />
            .Authentication.GetRequestToken(_consumerKey, _consumerSecret);     </p>
<p>        var response = requestToken.Request();<br />
        var result = response.AsToken();     </p>
<p>        if (result == null)<br />
        {<br />
            var error = response.AsError();<br />
            if (error != null)<br />
            {<br />
                throw new Exception(error.ErrorMessage);<br />
            }<br />
        }     </p>
<p>        return result;<br />
    }<br />
}</code></p>
<p>So when our user clicks the button, they will see a message from Twitter asking if they would like to grant our app access.&nbsp; From here the user can log into their Twitter account and verify our access to their account.</p>
<p>Easy so far!&nbsp; Our last piece of completing the OAuth access is set up our callback URL.&nbsp; Remember from our first post that we set up a callback URL as part of setting up our application.&nbsp; This URL is where Twitter will send the response back to our application.&nbsp; From here, we need to verify our response, then store the returned OAuth information for the user.</p>
<p>I set up my callback URL as welcome.aspx.&nbsp; The display of this page is just a label, where we can pass the result to our user.</p>
<p><code lang="csharp[lines]"><%@ Page Language="C#" AutoEventWireup="true" CodeFile="welcome.aspx.cs" Inherits="welcome" %>     </p>
<p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">     </p>
<p><html xmlns="http://www.w3.org/1999/xhtml"><br />
<head runat="server">     </p>
<p></head><br />
<body>     </p>
<form id="form1" runat="server">
<div>
        <asp:Label ID="welcomeLabel" runat="server" />
    </div>
</p></form>
<p></body><br />
</html></code></p>
<p>Once again in our code behind we will use the Consumer Key and Consumer Secret variables for our application.&nbsp; When this page is loaded we will first check to make sure we have a valid request that has been returned from Twitter.&nbsp; If not, you can trap this and do something like send the user back to our default page to try again.&nbsp; If we do have a valid request returned, we can validate the credentials passed back to us and display a nice neat welcome message to our user.</p>
<p><code lang="csharp[lines]">using System;<br />
using Dimebrain.TweetSharp.Extensions;<br />
using Dimebrain.TweetSharp.Fluent;<br />
using Dimebrain.TweetSharp.Model;    </p>
<p>public partial class welcome : System.Web.UI.Page<br />
{<br />
    private string _consumerKey = "YourKey";<br />
    private string _consumerSecret = "YourSecret";    </p>
<p>    protected void Page_Load(object sender, EventArgs e)<br />
    {<br />
        var requestToken = Request["oauth_token"];<br />
        if (requestToken == null)<br />
        {<br />
            //place your error code here, as no token was returned<br />
        }<br />
        else<br />
        {<br />
            // exchange returned request token for access token<br />
            var access = GetAccessToken(requestToken);    </p>
<p>            //verify returned info<br />
            var query = FluentTwitter.CreateRequest()<br />
                .AuthenticateWith(_consumerKey,<br />
                                  _consumerSecret,<br />
                                  access.Token,<br />
                                  access.TokenSecret)<br />
                .Account()<br />
                .VerifyCredentials()<br />
                .AsXml();    </p>
<p>            var response = query.Request();<br />
            var identity = response.AsUser();    </p>
<p>//store the returned values for future use<br />
//access.Token<br />
//access.TokenSecret    </p>
<p>            //display welcome message<br />
            welcomeLabel.Text = "Welcome " + identity.ScreenName + ", you now have access to our demo application.";<br />
        }<br />
    }    </p>
<p>    private OAuthToken GetAccessToken(string requestToken)<br />
    {<br />
        var accessToken = FluentTwitter.CreateRequest()<br />
            .Authentication.GetAccessToken(_consumerKey, _consumerSecret, requestToken);    </p>
<p>        var response = accessToken.Request();<br />
        var result = response.AsToken();    </p>
<p>        return result;<br />
    }<br />
}</code></p>
<p>We have now successfully set up access to our application for a user via OAuth.&nbsp; One step that is not in this demo is storing the values returned from Twitter.&nbsp; Depending on what you plan to do with your app, you will need to store these values for future API requests.&nbsp; TweetSharp will return to you two variables, Token and TokenSecret for the user.&nbsp; In my apps I store these in a database to grab for future use.</p>
<p>That&#8217;s it for today&#8217;s post.&nbsp; Our final post in this series will show you how to post status updates via your application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedevshack.com/post-2-use-the-net-tweetsharp-library-to-integrate-with-twitter-via-oauth/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>New Series: Use the .NET TweetSharp Library to Integrate with Twitter via OAuth</title>
		<link>http://www.thedevshack.com/new-series-use-the-net-tweetsharp-library-to-integrate-with-twitter-via-oauth/</link>
		<comments>http://www.thedevshack.com/new-series-use-the-net-tweetsharp-library-to-integrate-with-twitter-via-oauth/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 12:52:05 +0000</pubDate>
		<dc:creator>mfleming</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.thedevshack.com/?p=345</guid>
		<description><![CDATA[This is the first post on a new series I will be posting on integrating TweetSharp into your .NET applications.&#160; It will also show you how to use OAuth, as all the examples will be connecting to Twitter via OAuth. So what is TweetSharp?&#160; It&#8217;s a .NET library that hooks 100% into the Twitter API.&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first post on a new series I will be posting on integrating <a href="http://tweetsharp.com" target="_blank">TweetSharp</a> into your .NET applications.&nbsp; It will also show you how to use <a href="http://oauth.net" target="_blank">OAuth</a>, as all the examples will be connecting to Twitter via OAuth.<span id="more-345"></span></p>
<p>So what is TweetSharp?&nbsp; It&#8217;s a .NET library that hooks 100% into the Twitter API.&nbsp; The project is constantly updated as bugs and enhancements are pushed out to the Twitter API.&nbsp; I have been using TweetSharp in an application I wrote 6 months ago and it has worked flawless.</p>
<p>I will start by explaining what this series will cover.&nbsp; In the first post I will go over how you actually create an application on your Twitter account.&nbsp; By the end we will be grabbing our security tokens via OAuth and posting status updates to Twitter via OAuth.</p>
<p>Our first step in setting up our little application will be to register a new app with Twitter.&nbsp; In order to use the OAuth features, you must start by doing this.&nbsp; So let&#8217;s get started.</p>
<p>Log into your Twitter account via the web.&nbsp; Once you are logged in point your browser to <a href="http://twitter.com/apps">http://twitter.com/apps</a> where you will see a listing of your current apps, or a link to register a new application.</p>
<p><img class="size-full wp-image-346 alignnone" title="series1-1" src="http://www.thedevshack.com/wp-content/uploads/2009/11/series1-1.gif" alt="series1-1" width="585" height="428" /></p>
<p>Click on the link to register a new application.&nbsp; From this page you can start to enter in the details of your new application including an icon and the name of your app.&nbsp; Our most important areas of the signup for this post are to set the application type to &#8220;Browser&#8221;, the default access type to &#8220;Read &amp; Write&#8221; and the Callback URL.&nbsp; The Callback URL is where Twitter where send the user to after they grant your application access to their account via OAuth.&nbsp; We will discuss the code on this page in another post.&nbsp; It&#8217;s also important to note that this URL needs to be publicly available.&nbsp; For now set this to the full URL of your callback page.</p>
<p>Once you submit this page you will be taken to the main screen for your new application.&nbsp; Take note of all the information returned on this page, as it will be critical later on!&nbsp; Both the consumer key and the consumer secret fields will be used in our code to work with OAuth.</p>
<p>So now that your new app is set up, you can read a little more about <a href="http://tweetsharp.com" target="_blank">TweetSharp</a> and go ahead and <a href="http://tweetsharp.googlecode.com/" target="_blank">download</a> the library.&nbsp; Our next post will explain how to authorize a user&#8217;s Twitter account to use your application via OAuth.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedevshack.com/new-series-use-the-net-tweetsharp-library-to-integrate-with-twitter-via-oauth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What Language Would You Recommend To a Beginner?</title>
		<link>http://www.thedevshack.com/what-language-would-you-recommend-to-a-beginner/</link>
		<comments>http://www.thedevshack.com/what-language-would-you-recommend-to-a-beginner/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 12:23:00 +0000</pubDate>
		<dc:creator>mfleming</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.thedevshack.com/?p=342</guid>
		<description><![CDATA[Someone asked me an interesting question earlier this week that got me thinking quite a bit.&#160; Someone had a son that was interested in building web based applications and wanted to know what they should learn first.&#160; The answer to this question could have many answers depending on who&#160;it was asked to.&#160; Should they start [...]]]></description>
			<content:encoded><![CDATA[<p>Someone asked me an interesting question earlier this week that got me thinking quite a bit.&nbsp; Someone had a son that was interested in building web based applications and wanted to know what they should learn first.&nbsp; The answer to this question could have many answers depending on who&nbsp;it was asked to.&nbsp; Should they start with a scripting language (PHP, ColdFusion) or should they start with a more object oriented language (Java, .NET)?</p>
<p>I feel that one should start by learning the core basics of programming.&nbsp; Get your mind thinking in a logical way that allows you to solve problems.&nbsp; After all, that is essentially what programming is: You are solving a problem.&nbsp; I am not sure that learning a script based language would fully accomplish this.&nbsp; I ended up recommending .NET (C#)&nbsp;to start learning the fundamentals, then moving on from there.&nbsp;</p>
<p>If someone asked you this question, what would your answer be?&nbsp; I am very curious to hear the opinions of others on this topic, as I get asked this question more and more.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedevshack.com/what-language-would-you-recommend-to-a-beginner/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 and .NET 4.0 Beta 2 Available</title>
		<link>http://www.thedevshack.com/visual-studio-2010-and-net-4-0-beta-2-available/</link>
		<comments>http://www.thedevshack.com/visual-studio-2010-and-net-4-0-beta-2-available/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 10:51:13 +0000</pubDate>
		<dc:creator>mfleming</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.thedevshack.com/?p=322</guid>
		<description><![CDATA[If you are a MSDN subscriber I just wanted to pass along a quick note that Beta 2 of Visual Studio 2010 and .NET 4.0 are available for download.&#160; I played around with Beta 1 a little bit and ran across some issues with Visual Studio.&#160; Hopefully these have been addressed in Beta 2.]]></description>
			<content:encoded><![CDATA[<p>If you are a MSDN subscriber I just wanted to pass along a quick note that Beta 2 of Visual Studio 2010 and .NET 4.0 are available for download.&nbsp; I played around with Beta 1 a little bit and ran across some issues with Visual Studio.&nbsp; Hopefully these have been addressed in Beta 2.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedevshack.com/visual-studio-2010-and-net-4-0-beta-2-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clean web.config Files in .NET 4.0</title>
		<link>http://www.thedevshack.com/clean-web-config-files-in-net-4-0/</link>
		<comments>http://www.thedevshack.com/clean-web-config-files-in-net-4-0/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 11:12:39 +0000</pubDate>
		<dc:creator>mfleming</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.thedevshack.com/?p=304</guid>
		<description><![CDATA[If you have experience in programming in ASP.NET over the last few years, I am sure you have noticed how bloated the web.config file has become.&#160; Most of it is very confusing looking lines of various calls to load modules and handlers.&#160; It appears that is changing in .NET 4.0.&#160; Microsoft guru Scott Guthrie is [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-301" title="visual-studio" src="http://www.thedevshack.com/wp-content/uploads/2009/08/visual-studio.jpg" alt="visual-studio" width="137" height="82" />If you have experience in programming in ASP.NET over the last few years, I am sure you have noticed how bloated the web.config file has become.&nbsp; Most of it is very confusing looking lines of various calls to load modules and handlers.&nbsp; It appears that is changing in .NET 4.0.&nbsp; Microsoft guru Scott Guthrie is starting a series on his blog about the new features that are new to .NET 4.0.&nbsp; The first topic is how clean the web.config files will be.&nbsp; Check out Scott&#8217;s post and make sure you visit his site often to check out the rest of the topics in this new series.</p>
<p><a href="http://weblogs.asp.net/scottgu/archive/2009/08/25/clean-web-config-files-vs-2010-and-net-4-0-series.aspx" target="_blank">Clean Web.Config Files by Scott Guthrie</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedevshack.com/clean-web-config-files-in-net-4-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Visual Studio SP1 on Windows 7</title>
		<link>http://www.thedevshack.com/installing-visual-studio-sp1-on-windows-7/</link>
		<comments>http://www.thedevshack.com/installing-visual-studio-sp1-on-windows-7/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 21:29:45 +0000</pubDate>
		<dc:creator>mfleming</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.thedevshack.com/?p=300</guid>
		<description><![CDATA[Since installing Windows 7 RTM I have been slowly reinstalling all of my development programs.&#160; The only one that has given me a fit has been SP1 for Visual Studio 2008.&#160; The base program installed just fine, but SP1 failed every time.&#160; Even after trying some suggestions I saw while searching, nothing worked.&#160; But, earlier [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-301" title="visual-studio" src="http://www.thedevshack.com/wp-content/uploads/2009/08/visual-studio.jpg" alt="visual-studio" width="137" height="82" />Since installing Windows 7 RTM I have been slowly reinstalling all of my development programs.&nbsp; The only one that has given me a fit has been SP1 for Visual Studio 2008.&nbsp; The base program installed just fine, but SP1 failed every time.&nbsp; Even after trying some suggestions I saw while searching, nothing worked.&nbsp; But, earlier today I finally found success.&nbsp; Prior to firing up the install for SP1, run the following from the command line (make sure you fire up the command prompt as an administrator.</p>
<p><code lang="dos[lines]">reg delete HKLMSOFTWAREMicrosoftSQMClientWindowsDisabledSessions /va /f</code></p>
<p>After running this command, SP1 installed with no issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedevshack.com/installing-visual-studio-sp1-on-windows-7/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>.NET: Need To Drop The Span Tag From the Label Control? Use the Literal Control Instead</title>
		<link>http://www.thedevshack.com/net-need-to-drop-the-span-tag-from-the-label-control-use-the-literal-control-instead/</link>
		<comments>http://www.thedevshack.com/net-need-to-drop-the-span-tag-from-the-label-control-use-the-literal-control-instead/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 12:15:48 +0000</pubDate>
		<dc:creator>mfleming</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[label control]]></category>
		<category><![CDATA[span]]></category>

		<guid isPermaLink="false">http://www.thedevshack.com/?p=271</guid>
		<description><![CDATA[Have you ever had the need to use a label control, but you don&#8217;t need the span tag that the control automatically wraps around the text? Switch your control over to the Literal control instead. It serves the same general purpose as the label control, but will not wrap your output in those pesky span [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever had the need to use a label control, but you don&#8217;t need the span tag that the control automatically wraps around the text?  Switch your control over to the Literal control instead.  It serves the same general purpose as the label control, but will not wrap your output in those pesky span tags.</p>
<p><code lang="csharp[lines]"><br />
<asp:literal text="Some random value" runat="server" id="myControl"></asp:literal><br />
</code></p>
<p>You can then use your normal server side code to the change the value, just as you would the label control:</p>
<p><code lang="csharp[lines]"><br />
myControl.Text = "My new random value"<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedevshack.com/net-need-to-drop-the-span-tag-from-the-label-control-use-the-literal-control-instead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET: Converting a String to a GUID</title>
		<link>http://www.thedevshack.com/net-converting-a-string-to-a-guid/</link>
		<comments>http://www.thedevshack.com/net-converting-a-string-to-a-guid/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 11:12:28 +0000</pubDate>
		<dc:creator>mfleming</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.thedevshack.com/?p=245</guid>
		<description><![CDATA[This is just a quick little tip I came across yesterday. I was reading a Guid value out of a database and then passing it to .NET service along with some other data. The column type in the SQL Server database was a standard VARCHAR field, while the service itself was expecting a Guid data [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a quick little tip I came across yesterday.  I was reading a Guid value out of a database and then passing it to .NET service along with some other data.  The column type in the SQL Server database was a standard VARCHAR field, while the service itself was expecting a Guid data type to be passed in.  My first thought was that there was a little convert function that would do the work of converting my string to a Guid type, in the same way you can convert variables to integers, strings etc&#8230;   Quickly I found out this was not the case, and after searching online I came across a solution that was just as simple:</p>
<p><code lang="csharp[lines]"><br />
Guid id = new Guid(yourStringValue);<br />
</code></p>
<p>Easy enough, and now I had my Guid data type to pass into the service.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedevshack.com/net-converting-a-string-to-a-guid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET &#8211; Use VB Functions in C#</title>
		<link>http://www.thedevshack.com/net-use-vb-functions-in-c/</link>
		<comments>http://www.thedevshack.com/net-use-vb-functions-in-c/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 11:04:00 +0000</pubDate>
		<dc:creator>mfleming</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[vb functions]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.thedevshack.com/?p=237</guid>
		<description><![CDATA[Yesterday I was working on a .NET website that has a couple of cost calculators in them. The user inputs 10 or so data points and the application will calculate their costs and savings. While working on some validation of the user submitted data, I need to make sure all fields were numeric in value. [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I was working on a .NET website that has a couple of cost calculators in them.  The user inputs 10 or so data points and the application will calculate their costs and savings.  While working on some validation of the user submitted data, I need to make sure all fields were numeric in value.  Well guess what?  C# does not have an easy built in function to check for a numeric value.  Most of the things I came across were hacks, try/catches or trying to cast the value to something numeric and then seeing the result.  I then came across a nice little tip.  VB does have a simple IsNumeric function (as does classic ASP).  So how can you use this in your C# code?</p>
<p>The answer is very simple.  All you need to do is add a reference to a .NET library and then tack on a using statement for the library.  You can then use some of the VB functions right inside your C# code.</p>
<p>To add a reference in Visual Studio, just right click on the root item of your project and select Add Reference.  From the .NET tab scroll down and find Microsoft.VisualBasic.  Then click the OK button.  At the top of your code behind file add:<br />
<code lang="csharp[lines]"><br />
using Microsoft.VisualBasic;<br />
</code></p>
<p>That&#8217;s it!  In my application I can now use the VB function for IsNumeric like so:<br />
<code lang="csharp[lines]"><br />
if (Information.IsNumeric(Field1.Text) &#038;&#038; Information.IsNumeric(Field2.Text))<br />
{<br />
     //Do something here<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedevshack.com/net-use-vb-functions-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion &amp; .NET: Comparing List Functions</title>
		<link>http://www.thedevshack.com/coldfusion-net-comparing-list-functions/</link>
		<comments>http://www.thedevshack.com/coldfusion-net-comparing-list-functions/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 11:31:18 +0000</pubDate>
		<dc:creator>mfleming</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://www.thedevshack.com/?p=232</guid>
		<description><![CDATA[It&#8217;s been awhile since I have added a new post to the series that compares code in ColdFusion &#038; .NET. Today&#8217;s post covers something I use quite a bit throughout some of my applications: storing values in a list type format. If you have programmed in ColdFusion for years, you take the built in list [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been awhile since I have added a new post to the series that compares code in ColdFusion &#038; .NET.  Today&#8217;s post covers something I use quite a bit throughout some of my applications: storing values in a list type format.  If you have programmed in ColdFusion for years, you take the built in list functions for granted.  Today&#8217;s example covers storing a simple list of ID&#8217;s in a variable.  You could use this for storing user group associations or something like that.  The example will show you how to add an item to the list and then search the list to see if a certain value is stored within it.</p>
<p>First up the ColdFusion code:</p>
<p><code lang="cfm[lines]"><br />
<cfset variables.newID = CreateUUID()><br />
<cfset variables.idList = ""><br />
<cfset variables.idList = ListAppend(variables.idList, variables.newID)></p>
<p><cfif ListFindNoCase(variables.idList, variables.newID)><br />
	Value Found<br />
<cfelse><br />
	Value Not Found<br />
</cfif><br />
</code></p>
<p>This code is fairly simple.  We create a UUID, use the ListAppend function to add the value to our list, then use ListFindNoCase to see if our value is in the list.</p>
<p>Now for the .NET code:</p>
<p><code lang="csharp[lines]">using System;<br />
using System.Collections.Generic;<br />
using System.Web;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
using System.Collections;</p>
<p>public partial class list_test : System.Web.UI.Page<br />
{<br />
    protected void Page_Load(object sender, EventArgs e)<br />
    {<br />
        Guid newID = System.Guid.NewGuid();<br />
        ArrayList idList = new ArrayList();<br />
        idList.Add(newID);</p>
<p>        if (idList.Contains(newID) == true)<br />
            foundLabel.Text = "Item Found";<br />
        else<br />
            foundLabel.Text = "Item Not Found";<br />
    }<br />
}</code></p>
<p>This code is fairly simple as well.  The big difference between the two languages is that .NET treats the list as an array, so we first set uo our ArrayList object, add our Guid value to the ArrayList, then search for our value using the Contains function.  We then update the value of a label on our front end page depending on our results.</p>
<p>So as you can see using lists is easy no matter which language you use.  Both languages also allow you to store your lists in the session scope as well.  The one pointer for doing this in .NET is you must cast your value back out to an ArrayList object when reading it from the session:</p>
<p><code lang="csharp[lines]"><br />
ArrayList newsList = (ArrayList)Session["newsList"];<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedevshack.com/coldfusion-net-comparing-list-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

