Failure with Nested WebForm Callbacks

Posted by Matt | Filed under , ,

I am working on an ASP.NET application that requires some WebForm callbacks.  However, I am running into the following error:

Microsoft JScript runtime error: '__pendingCallbacks[...].async' is null or not an object

This error appears in the code below.

function WebForm_CallbackComplete() {
  for (var i = 0; i < __pendingCallbacks.length; i++) {
    callbackObject = __pendingCallbacks[i];
    if (callbackObject && callbackObject.xmlRequest && 
        (callbackObject.xmlRequest.readyState == 4)) {
      WebForm_ExecuteCallback(callbackObject);
      if (!__pendingCallbacks[i].async) {
        __synchronousCallBackIndex = -1;
      }
      __pendingCallbacks[i] = null;
      var callbackFrameID = "__CALLBACKFRAME" + i;
      var xmlRequestFrame = document.getElementById(callbackFrameID);
      if (xmlRequestFrame) {
        xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
      }
    }
  }
}

After doing some Googling, I found out that there was a previously common problem with this same line of code. The previous error had a scope issue with the variable 'i'.  However, when using Visual Studio 2008, and as you see above, this scope issue is fixed by adding ‘var’ in the for loop.

So what’s the issue now?

It appears to be an issue of calling a web callback synchronously from within the end callback of a previous web callback.  Essentially, I am nesting WebForm callbacks:  calling a second before the first is 100% complete.

Here’s what is happening.  I’m calling ‘WebForm_DoCallback’ from my Javascript and that’s going to the web server and returning.  When it returns, Microsoft’s system calls my end-of-callback event callback.  In this function, I am calling ‘WebForm_DoCallback’ again.  It looks like Microsoft’s synchronous callback system does not like nested callbacks.  The second call is destroying the __pendingCallbacks array before the first call completes.

I was able to avoid the issue by doing the following:

var __data = null;
function End_Callback_Proxy(arg, context) {
  __data = arg;
  window.setTimeout('End_Callback_Helper()', 0);
}
function End_Callback_Helper() {
  End_Callback(__data, 'ResetMarker');
}

Here, I set the event callback to be ‘End_Callback_Proxy’ instead of ‘End_Callback’.  This saves the data from the callback to a variable, and tells the window to call ‘End_Callback_Helper’ a little bit later.  This allows the current callback to complete before the next one is called.

I have submitted this issue to Microsoft Connect.  You can view the issue here.

Where Do Programmers Find Visual Designers?

Posted by Matt | Filed under , , , , ,

Have you ever created the world’s next best application, to have it be 100% bug-free, 100% intuitive, but it’s missing that nice visual appeal?  Have you created an ASP.NET web application, but you needed a web designer to give it some snazz?  Have you created a WPF or Silverlight application, but you needed a WPF designer guru, or Blend expert, to punch up the program?  Have you created an MFC application, only to need a couple more icons to go on your toolbars.

If you’ve answered ‘yes’ to any of these questions, then you’re not alone.

Larger companies can afford to have a programming team and a graphics team on their payroll.  As a start-up, entrepreneur, hobbyist, or small company, we don’t have that luxury.  Personally, I’ve experienced all of the above scenarios:  I can write code, but I cannot draw my way out of a colouring book.

So the question is:  where do programmers find visual designers?

There are some companies which can create great-looking themes for WPF. One such company is Nukeation with their Reuxables products.  This will allow you to create a non-standard looking interface, but it’s not a big change from an ordinary program.

Some companies can provide user interface consulting. Again, Nukeation can do this too.  If you have the money, this is not a bad route to take.  Here’s a case study for Frog Design that designed a very attractive business solution.

But how can a lowly programmer end up with something like this?

When Josh Smith created Podder, he initially got Grant Hinkson to design a slick user interface for him, but I think he already had a working relationship with him.  Following that, he held a contest for people to submit skins for this creation.  Not many programmers can hold contests, but it’s not a bad approach.

So I’m asking (because I really want to know):

As a programmer, what do you do when you need graphics, design, or other visual elements?

As a graphic designer, how do you find web or WPF jobs?

Does the world need a classified-type place for programmers and designers to meet and find jobs?  Will programmers find it useful to find artists?  Will graphic designers use it to find paying jobs?

Or does it already exist?

What do you think?

Choosing an ASP.NET Web Host

Posted by Matt | Filed under , , ,

As an ASP.NET developer, choosing a web host to host your web application is sometimes as important, and as difficult, as choosing what web application you will create.  Unless you’re working for a company that hosts it’s own web applications, you’ll need to search for a host to host your application.  Selecting the right host for you is very important.  Below are some things to look for when selecting your host.

Types of Hosting

There are a few different kinds of hosts.  Some companies provide multiple offerings.

Shared Web Hosting

This type of hosting hosts many different web applications on the same web server.  This is often the cheapest route to take and is great for a small or start-up application.  However, if your application grows, you may notice performance degradation and you’ll want to move to another type of host.  You almost always never have access to a Windows desktop:  instead, everything is done through a control panel (more about this later).

Virtual Private Servers

This type of hosting hosts many virtual servers on a single server.  You usually are the sole user of the virtual server, but you share the real server’s CPU with other virtual servers.  This option gives you full control over the hosting environment as if it’s a real computer:  you have remote access to the desktop, you can install additional software, etc.

Managed Dedicated Servers

This type of hosting gives you a dedicated computer for your use.  You do not share the computer with anyone else.  However, you do not need to manage the day-to-day administration of the computer like daily backups, etc.  These sorts of things gets managed by the hosting company and is usually included in the hosting fee.

Dedicated Hosting

This type of hosting gives you 100% complete control over your computer.  You can do whatever you want with it:  but the hosting company won’t do anything for you except give you internet bandwidth.

Programming Features

Platforms

Some things to look for when selecting a host is what programming platforms do they support.  Some do not support ASP.NET, and as an ASP.NET programmer, you’ll need this. 

Versions

You’ll want to be careful about what versions of ASP.NET the hosts support.  Some hosts only support ASP.NET 2.0.  If your application uses Windows Communication Foundation or Workflow Foundation, you may be out of luck with a strictly-2.0 provider.  You’ll want to find a host that supports ASP.NET 3.5.

Silverlight

Does your application use Silverlight?  If so, make sure you can use that with your host.

Databases

Does your application require a SQL database?  Most ASP.NET hosts provide Microsoft SQL Server to their clients.  For some it’s included, and some it’s extra.  Find out any extra costs you may need to fork over.  Maybe your application can work with MySQL instead?  If so, that’s often a cheaper alternative.

In short, collect the requirements for your application, and double check that your host supports all of the requirements.

Below is a list of some ASP.NET web hosts (in no particular order).

iTunes skin for ASP.NET GridView and ListView

Posted by Matt | Filed under

Matt Berseth has created a cool skin for ASP.NET ListView and GridView based on iTunes.  More information can be found here.