Skip to main content
I'm streaming on Twitch right now. You should stop by. Let's go!

Tagged: dot net

  • Using ASP.NET connection strings in PowerShell scripts


    I found a trick for loading ASP.NET connectionString elements from configuration files for use in PowerShell scripts, and I figured I would share it with the class. They are, as should have been obvious to me much sooner, simply XML nodes in an XML document. This comes in pretty handy when you have …

  • ASP.NET/C# image resizer for responsive layouts


    I will probably elaborate on this a bit further when I find some more time, but for now, this post is going to be mostly code. What I have here is a relatively simple way to generate images that are resized server-side based on the screen dimensions (note: not window dimensions) of the web browser requesting them. This way, you're not sending huge images to phones. Pair this with some CSS to scale your images to fit their containers, and you're cooking with gas!  …

  • Dynamic GridView rows in ASP.NET


    Here's a simple proof-of-concept for dynamically adding and removing rows in an ASP.NET GridView control while maintaining the existing data.  …

  • Validating file uploads in Sitecore WFFM


    Our Sitecore installation was in dire need of a way to lock down file uploads on forms built with the Web Forms for Marketers (WFFM) module; out of the box, it doesn't do any checking at all, which can lead to some risky situations. I tacked on a simple whitelist attribute to the UploadFile control, and our security engineer can breathe easy.  …

  • LDAP authentication with C#


    LDAP, or Lightweight Directory Access Protocol, is a convenient, central repository for a system's personnel information. LDAP (and other Active Directory services) are widely-used by organizations big and small to consolidate user credentials and identification data. For instance: a reporting services application, a webmail client, and a database administration suite can all read from the same Directory, with no need for replicating user information. John Doe only has to remember one password for all systems. When he changes it, those changes cascade across the board.  …

  • rexCrawler and HelpfulHighlighter are now open source


    After having dipped my toe in the water of open source with some Arachni module changes and the development of a simple WordPress plugin, I've finally taken the plunge; two of my personal projects are now completely open source, and hosted on github. Much of the code is stale—and somewhat embarrassing—but I figured that it was high time I shrug off that self-defensive apprehension and use it as fuel to make me a better developer.  …

  • Using WSE 3.0 with Visual Studio 2008 and .NET 3.5


    While I'm sure many of you have "moved on" to Visual Studio 2010, there are a large number of us still using 2008. Recently, my shop needed to write some code for interfacing with a vendor's web services. No problem, right? Well… not quite. It was quite an undertaking to get a functional wrapper class for our vendor's web service shoehorned into Visual Studio 2008 and the .NET 3.5 platform.  …

  • Check all CheckBoxes in a GridView using jQuery


    If you're working with a GridView control where you've built a CheckBox control into each row of data displayed, odds are, it would be convenient for your users if a "Check/Un-check All" option was available. The following example will show how to do just that; and with only the tiniest bit of jQuery script!  …

  • Custom error messages with ValidationSummary in ASP.NET


    Sometimes, there are problems encountered in a code-behind file that don't warrant the extra work and mark-up that would otherwise be required to add CustomValidator controls to the page for displaying error messages to the user through your ValidationSummary. Wouldn't it be nice if you could (somewhat) easily take care of it in your code-behind file alone, without adding additional clutter to your UserControl/Page/etc.? Well, you can! The following IValidator extension class can be added to a Page's Validators list with ease for displaying custom error messages.  …

  • Programmatically modifying file permissions in .NET


    For one reason or another, somewhere down the line, you're probably going to want to modify a file's access permissions from your code. Maybe your users have a nasty habit of overwriting them, or you want to ensure that newly-created files are given a specific permission mask. Whatever the reason, the following C# code example shows how to modify a file's access permissions using the System.Security.Principal and System.Security.AccessControl namespaces.  …

  • Image dimension Field Validator for Sitecore CMS


    This StandardValidator extension will determine whether or not a given ImageField's source image's height and width match with given parameters. Either parameter can be omitted if, for instance, you only care about validating the width of an image (or conversely, only the height).  …

  • Currency Field Validator for Sitecore CMS


    This StandardValidator extension will determine whether or not a given field value passes for currency. In order to do so, it must meet the following requirements: It must pass decimal.TryParse() It must not have more than 2 digits past the decimal point Obviously, this does not fit all international systems—however, in my case, it works for my project (which does not require localization). The code could easily be customized to accommodate additional formats.  …

  • bulkRename v1.1


    A while back (in 2008), I wrote a simple system utility with VB.NET which leverages the power of regular expressions to rename files in bulk according to a pattern. I've had to use it several times recently after placing it on a metaphorical shelf to gather dust, and it got me thinking: Maybe other people can benefit from this utility. That's what software is supposed to be all about, right?  …

  • Replacing MS Word's quotation marks in VB.NET


    When dealing with text pasted from Microsoft Word, the presence of "special" (read: non-ASCII) quotation marks and apostrophes can be quite troublesome. Here's a simple way to convert them to "standard" (read: ASCII) quotation marks and apostrophes… VB.NET Code: #!vbnet …

  • Files as Resources in .NET projects


    Have you ever found that sleek application you wrote slowly becoming scattered over time with the use of external files? Say you want to create a simple GUI application that can be distributed as just an executable file. What if you want to use a *.chm help file? This article will show how to embed that file in your executable via the .NET concept of Resources.  …

  • Retrieving user properties from LDAP with VB.NET


    As discussed in an earlier post, LDAP can be a wonderful tool for centrally storing user information and credentials. I've written about how to authenticate against the LDAP repository… but what if you're just looking for information?  …

  • LDAP authentication with VB.NET


    LDAP, or Lightweight Directory Access Protocol, is a convenient, central repository for a system's personnel information. LDAP (and other Active Directory services) are widely-used by organizations big and small to consolidate user credentials and identification data. For instance: a reporting services application, a webmail client, and a database administration suite can all read from the same Directory, with no need for replicating user information. John Doe only has to remember one password for all systems. When he changes it, those changes cascade across the board.  …

  • Simple MD5 hashes in VB.NET


    MD5 (Message Digest) hashes are a simple, efficient way to encode/encrypt information to be passed around. Rather than containing the data itself, an MD5 hash is merely a fingerprint of the information. The hash cannot be decrypted, but is instead compared to other hashed values for verification. This can be a handy tool when authenticating a user's entered password as one simple example. Here is a very efficient, simple function that can be used to generate an MD5 hash for a given string…  …

  • Using the ConnectionStrings element in ASP.NET web.config


    If you are building a series of web applications that may rely on duplicate data (such as connection strings for pages that query databases), or you want to separate certain constants from your other code, you need a centralized method for storing and referencing that data. In this case, the ConnectionStrings element in the web.config file of either your application's root directory, parent directory, or the web server root directory–depending on your application's inheritance–can prove incredibly useful.  …

  • Prepared SQL statements in VB.NET


    Thousands of websites have been hit lately by the rash of SQL injections being perpetrated en-masse. Most languages (current versions, at least) have a procedure for separating parameters from the query they augment in an effort to prevent SQL injection, and VB.NET is no different.  …

View all tags