Posted by Mike Fleming | Posted in .NET, Twitter | Posted on 23-11-2009
0
Today’s post is the second in a series explaining how to integrate TweetSharp into your .NET application using OAuth. In our first post we covered the basics of registering a new application with Twitter. This post will cover how you ask, then grant access from someone’s Twitter account to your new application using OAuth.
Posted by Mike Fleming | Posted in .NET, Twitter | Posted on 20-11-2009
0
This is the first post on a new series I will be posting on integrating TweetSharp into your .NET applications. It will also show you how to use OAuth, as all the examples will be connecting to Twitter via OAuth.
Posted by Mike Fleming | Posted in .NET, General | Posted on 18-11-2009
6
Someone asked me an interesting question earlier this week that got me thinking quite a bit. Someone had a son that was interested in building web based applications and wanted to know what they should learn first. The answer to this question could have many answers depending on who it was asked to. Should they start with a scripting language (PHP, ColdFusion) or should they start with a more object oriented language (Java, .NET)?
I feel that one should start by learning the core basics of programming. Get your mind thinking in a logical way that allows you to solve problems. After all, that is essentially what programming is: You are solving a problem. I am not sure that learning a script based language would fully accomplish this. I ended up recommending .NET (C#) to start learning the fundamentals, then moving on from there.
If someone asked you this question, what would your answer be? I am very curious to hear the opinions of others on this topic, as I get asked this question more and more.
Posted by Mike Fleming | Posted in .NET | Posted on 20-10-2009
0
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. I played around with Beta 1 a little bit and ran across some issues with Visual Studio. Hopefully these have been addressed in Beta 2.
Posted by Mike Fleming | Posted in .NET | Posted on 26-08-2009
0
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. Most of it is very confusing looking lines of various calls to load modules and handlers. It appears that is changing in .NET 4.0. Microsoft guru Scott Guthrie is starting a series on his blog about the new features that are new to .NET 4.0. The first topic is how clean the web.config files will be. Check out Scott’s post and make sure you visit his site often to check out the rest of the topics in this new series.
Clean Web.Config Files by Scott Guthrie
Posted by Mike Fleming | Posted in .NET, Windows | Posted on 16-08-2009
1
Since installing Windows 7 RTM I have been slowly reinstalling all of my development programs. The only one that has given me a fit has been SP1 for Visual Studio 2008. The base program installed just fine, but SP1 failed every time. Even after trying some suggestions I saw while searching, nothing worked. But, earlier today I finally found success. 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.
| 1 | reg delete HKLM\SOFTWARE\Microsoft\SQMClient\Windows\DisabledSessions /va /f |
After running this command, SP1 installed with no issues.
Posted by Mike Fleming | Posted in .NET | Posted on 27-07-2009
0
Have you ever had the need to use a label control, but you don’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.
| 1 | |
| 2 | <asp:literal text="Some random value" runat="server" id="myControl"></asp:literal> |
| 3 | |
You can then use your normal server side code to the change the value, just as you would the label control:
| 1 | |
| 2 | myControl.Text = "My new random value" |
| 3 | |
Posted by Mike Fleming | Posted in .NET | Posted on 24-06-2009
0
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… Quickly I found out this was not the case, and after searching online I came across a solution that was just as simple:
| 1 | |
| 2 | Guid id = new Guid(yourStringValue); |
| 3 | |
Easy enough, and now I had my Guid data type to pass into the service.
Posted by Mike Fleming | Posted in .NET | Posted on 16-06-2009
0
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?
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.
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:
| 1 | |
| 2 | using Microsoft.VisualBasic; |
| 3 | |
That’s it! In my application I can now use the VB function for IsNumeric like so:
| 1 | |
| 2 | if (Information.IsNumeric(Field1.Text) && Information.IsNumeric(Field2.Text)) |
| 3 | { |
| 4 | //Do something here |
| 5 | } |
| 6 | |
Posted by Mike Fleming | Posted in .NET, ColdFusion | Posted on 15-06-2009
0
It’s been awhile since I have added a new post to the series that compares code in ColdFusion & .NET. Today’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’s example covers storing a simple list of ID’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.
First up the ColdFusion code:
| 01 | |
| 02 | <cfset variables.newID = CreateUUID()> |
| 03 | <cfset variables.idList = ""> |
| 04 | <cfset variables.idList = ListAppend(variables.idList, variables.newID)> |
| 05 | |
| 06 | <cfif ListFindNoCase(variables.idList, variables.newID)> |
| 07 | Value Found |
| 08 | <cfelse> |
| 09 | Value Not Found |
| 10 | </cfif> |
| 11 | |
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.
Now for the .NET code:
| 01 | using System; |
| 02 | using System.Collections.Generic; |
| 03 | using System.Web; |
| 04 | using System.Web.UI; |
| 05 | using System.Web.UI.WebControls; |
| 06 | using System.Collections; |
| 07 | |
| 08 | public partial class list_test : System.Web.UI.Page |
| 09 | { |
| 10 | protected void Page_Load(object sender, EventArgs e) |
| 11 | { |
| 12 | Guid newID = System.Guid.NewGuid(); |
| 13 | ArrayList idList = new ArrayList(); |
| 14 | idList.Add(newID); |
| 15 | |
| 16 | if (idList.Contains(newID) == true) |
| 17 | foundLabel.Text = "Item Found"; |
| 18 | else |
| 19 | foundLabel.Text = "Item Not Found"; |
| 20 | } |
| 21 | } |
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.
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:
| 1 | |
| 2 | ArrayList newsList = (ArrayList)Session["newsList"]; |
| 3 | |