Chad Scharf's Weblog
It's always time to upgrade!

Creating a JavaScript HashTable

Friday, 2 May 2008 16:10 by Chad

I use a lot of configuration and provider driven services and variables for developing web applications. Let's face it, I don't like to recompile. I recently had the need to share my Web.config settings with the client code, but didn't want to declare a variable for every possible setting, I just wanted to dynamically create the script of configuration settings in some collection and have access to that in my client side code. Because I wanted this collection to act just like a HashTable in System.Collections, I decided to create a JavaScript type to mirror the storage and access paradigm of the HashTable for use in my applications. More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Shrinking JavaScript Arrays

Friday, 11 April 2008 20:21 by Chad

Recently I've found myself writing a ton of client code in a new pure JavaScript/WCF project I am working on. Since most of the programming I'm doing for the UI is in JavaScript files, I've found myself having to work with the Array object for many different things. The one thing I've noticed however, is that you cannot remove an item from a JavaScript array, say, in the middle of the array and have the array size shrink without losing data at either end, however having to check for array_name[i] != null every single time I iterate the array was getting annoying, to say the least.

I decided to flex the muscle of the prototype, which in JavaScript allows you to extend a types method and properties. This new method I created, called shrink(), aptly removes all of the nulls from my array and shrinks the total length without losing any data. I'm not sure how efficient it is, but it works and I no longer have to check for null where at least it doesn't make sense to anyway.

Array.prototype.shrink = function() {
    var sync = new Array();
    while (this.length > 0) {
        var obj = this.shift();
        if (obj !== null) sync.push(obj);
    }
    while (sync.length > 0) {
        var obj = sync.shift();
        if (obj !== null) this.push(obj);
    }
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   The Client Side
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Protecting PDF files in IIS 6 using Forms Authentication

Thursday, 3 April 2008 23:32 by Chad

Problem

We have a very simple ASP.NET web site that uses the built in Forms Authentication provider out of the box for users, roles and security. Our internal business customers have hundreds of PDF documents that should only be accessible for specific users or roles within the company. A majority of users that need access to these files are outside the company firewall and do not have VPN access. The site must be hosted on Windows Server 2003 using IIS 6.

Although this problem could be solved in many ways, I wanted to make the site as dynamic as possible since our web master would need to make constant changes to files, structure, etc and we did not want a programmer having to make changes to specific code or a DBA maintaining a database of files, paths, etc. We also wanted to avoid using a network file share to host the files or wrap the site using Plain Text authentication. More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Readability, Sub-Queries in LINQ

Sunday, 30 March 2008 14:39 by Chad

I've been working with LINQ and LINQ to SQL for a while now and I have to say, it definitely makes object enumeration, data access and binding extremely easy and efficient. Even the dynamic SQL it generates using LINQ to SQL is acceptable in efficiency and performance. One thing I noticed however is when you need to do complex sub queries or provide summary information within nested levels of relationships, the code can become pretty messy, until I discovered you can write LINQ statements within a generic type from inside an existing LINQ statement. More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , ,
Categories:   LINQ
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

You can’t always blame Bill when Vista breaks

Friday, 11 January 2008 22:51 by Chad

Just recently I decided to upgrade my development machine at the office from Windows XP to Windows Vista. Taking into consideration the ability to play around with the new IIS7, as well as take the opportunity to upgrade to Visual Studio 2008 Team Suite. I can say I'm happy that I did, I even did a clean install since Vista Enterprise did not support an upgrade from XP. Then the fun started. After spending a day and a half re-installing all of my development tools, MS Office, hunting down new drivers for the video card, sound card as well as running Windows Updates, etc I was up and running without a care in the world. More...

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , , ,
Categories:   IIS7 | Windows Vista
Actions:   E-mail | Permalink | Comments (1) | Comment RSSRSS comment feed

Checking for a null session is a serious matter

Wednesday, 9 January 2008 11:55 by Chad

While using Infragistics NetAdvantage for ASP.NET I noticed a bug while working with the UltraGauge (WebGauge) control. It turns out that if you disable session state for the page that this control is on or for the entire web application as I had done for performance reasons, you get a nasty error:

"Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration." More...

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Introductions

Tuesday, 1 January 2008 01:21 by Chad

First of all, I have to give a major thanks to the BlogEngine.NET team. Without their amazing contributions to the .NET development community it would have taken me weeks in my spare time to get this blog up and running; that is with ½ the functionality because frankly, like most developers I know, I typically don't have spare time. This site is running off of the latest build, 1.3, and has a custom theme that I created for my own taste, which thanks to the team and the ease of the CSS compliant design, took only a couple of hours of development. If you like it, feel free to download it and use it (with proper credit of course Wink). You can download it here: Waves.zip (462.14 kb). More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , ,
Categories:   General
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed