Browse by Tags

Related Posts
  • Blog Post: Close Registry Keys After Use

    To open a windows registry key using C#, the code would look something like this: RegistryKey rk = Microsoft.Win32. Registry .LocalMachine.OpenSubKey( "Software\\TWC\\Applications" , true ); The RegistryKey object has lots of methods on it to CreateSubKey, DeleteSubKey, SetValue, DeleteValue...
  • Blog Post: Use an Image in a HyperLinkColumn

    I’ve seen a lot of posts on boards of people inquiring how to utilize an image in a hyperlinkcolumn.  I found those posts, because I was trying to do the same thing.  In my codebehind, I had some custom things going on for the link, and really didn’t feel like comprimising any of that by calling...
  • Blog Post: Formatting Strings in a DataGrid

    In my opinion, one of the coolest .net controls is the DataGrid.  There is sooo much you can do with this puppy.  One of the things I like most about it is how you can choose to control or not control how data is rendered.  Which brings me to the topic of this post, how to format a string...
  • Blog Post: Determine how many records are in a DataSet

    To determine how many records are in a dataset, you can use the Count method of the Rows in a table (last line in code).         // New DataSet         DataSet dbSet = new DataSet ();          ...
  • Blog Post: How to swap two strings

    using System; class SwappinStrings {     static void SwapStrings( ref string s1, ref string s2)     // The string parameter x is passed by reference.     // Any changes on parameters will affect the original variables.     {        ...
  • Blog Post: Including a file in a Web Deployment Project

    Argh Argh.  I’m precompiling a website (msbuild) and then building an installer for deploying it.  For the build, I’m use WDP.  However; for whatever silly reason Visual Studio ignores file types of .lic   So I have a license file that won’t get built, and to be honest I don...
  • Blog Post: Allow Only Numbers In A String - C#

    Often you may have user input that needs to only be numbers, and the input doesn’t allow characters.  There is javascript that you can put on the front end to limit what keystrokes can be made in an input field; however, there are still ways around it.  Here’s a good filter method that you...
  • Blog Post: Activating ActiveX Controls

    Since Microsoft has released their new security around ActiveX Controls, you may have noticed that Internet Explorer isn’t too friendly torwards Flash anymore. For more detailed information on the new security and how Control Activation works here, Activating ActiveX Controls . Here is a quick example...
  • Blog Post: Convert VB to C#

    Ever find a tutorial or code sample that will resolve your current issue…. and Argh!  It’s in VB.  It’s happened to me a thousand times. This experimental web app can convert that foreign language for you:  http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx . I’ve had some...
  • Blog Post: ImageButton in DataGrid and DataGrid.ItemCommand Event

    I recently had an ImageButton in a DataGrid, and for whatever reason it wouldn’t fire the DataGrid.ItemCommand event.  After beating my head on the keyboard for an entire day, I finally found the problem. When you are binding the grid (or calling the method that handles the binding) in the page_load...
  • Blog Post: Compiler Error Message: CS0030: Cannot convert type ‘ASP.login_aspx’ to ‘System.Web.UI.WebControls.Login’

    Argh. What a silly error this is. There are a couple of things that need to happen for this to happen in .net. 1. You precompiled your app (2.0) 2. You publish your site as ‘updateable’ 3. You named a page that is the same as a Class in .net Most developers call their login page: Login.aspx. When you...
  • Blog Post: Regular Expression Library

    Regular Expressions.  Joy oh Joy.  Here’s a great site to help ease the pain in writing one: Regular Expression Library .  They have over a thousand indexed expressions and it even has an online tool to help you test expressions: http://www.regexlib.com/RETester.aspx I used it to help...
  • Blog Post: Adding a ListItem to a dynamic dropdown list

    If you manually add a listitem to a dynamic dropdown list, ensure that you set the appenddatabounditems attribute to true.  If you don’t, the dynamic items will overwrite the ones you manually added. < asp : dropdownlist id ="DevelopmentCycleDropDown" runat ="server" appenddatabounditems...
  • Blog Post: Difference between two Dates

    Here’s some useful code if you need to know how much time has elapsed between two days.         DateTime oldDate = new DateTime (2005, 7, 31);         DateTime newDate = DateTime .Now;          ...
  • Blog Post: Check to see if a string is empty

    There are several ways to check a string to see if it’s empty.  However, you should try to always use the following method.  It’s faster, and uses less resources.  This may seem like a minimal piece of code - but if you were checking strings through out your application, it all adds up...