ASP.Net Ajax: make sure you check for IsAsync!

November 29, 2007

I am experimenting with a couple of Ajax controls from the AjaxControlsToolkit. I have read quite a couple of articles about them, but you never know when to apply that knowledge you acquired by browsing around.

Well, today I hit a problem using a CalendarExtender in a FormView on an UpdatePanel:

Selecting the Edit mode of the FormView always raised a Javascript exception stating a Javascript syntax error, and a .js file not being able to be loaded.

After googling around and finding that I am the only one on the planet that experiences that problem, I remembered an article about Ajax traps and handling of asynchronous events.

Read the rest of this entry »


Visual Studio compiler messages

November 28, 2007

Almost every programming languages knows the concept of string arrays. You have them in C, C++, Pascal, Delphi, you name it. (Do you miss Basic’s READ / DATA statement?).

Not so C#. Trying a declaration like

protected const string[] rgsExt = new string[] { ".pdf", ".html" };

brings up the meaningful compiler error message

A const of reference type other than string can only be
initialized with null

As you would expect, pressing F1 brings up a help page which describes what you did wrong. Or does it?

Read the rest of this entry »


Handling CollapsiblePanelExtender events in Javascript

November 27, 2007

I am currently migrating two ASP.Net projects to VS 2005 AjaxControlToolkit.

Of course I had a glance at the samples, and compared the functionality to its open source counterpart, namely Prototype plus Scriptaculous.

When I built a navigation menu using a couple of CollapsiblePanelExtender controls, I ran across two problems:

1) It seems extremely difficult to store the current state of CollapsiblePanelExtenders to be retrieved in the next GET. The simplest solution would be an asynchronous callback from the extender, but that functionality is not included in the framework.

2) I wanted to collapse the whole navigation menu, which is kept inside an HTML table. To keep the table format static, I used a style=”width: 200px” attribute. However, if the navigation menu is to hide, the width should be set to the size of the expanding icon.

Read the rest of this entry »


HTTP Status Codes in C#

November 14, 2007

I’m in the middle of writing ab WebDAV HttpHandler. Strangely, I could not find a list of HTTP Status Code constants in C# on the web, and transformed the codes from the RFCs myself.

I chose to distinguish between HTTP codes and WebDAV codes. Since WebDAV sits on top of HTTP, they share some codes, so I derived the WebdavStatusCode class from the HttpStatusCode class.
Read the rest of this entry »


API call missing in .Net? Search for NativeMethods!

November 6, 2007

You may have noticed that the .Net framework does not cover every aspect of Windows programming. Sometimes API calls or whole features are simply not accessible when programming in .Net.

However I found that there’s a lot of interfacing code available on the net that makes WinAPI calls and structures available as static methods of static classes, using the DllImport feature.

The static class is usually called NativeMethods, and googling “NativeMethods” plus the API call or DLL you’d like to call, should deliver results quickly.


Monitoring Remote Webserver Event Logs

November 3, 2007

The Get-WMIObject commandlet lets you access a remote event log using the Win32_NTLogEvent class.

This little Powershell script filters the remote event log for IIS-generated entries within a selected date range:
Read the rest of this entry »


Follow

Get every new post delivered to your Inbox.