WebLog Posts in Category AJAX


Passing multiple simple POST Values to ASP.NET Web API
September 11, 2012 @ 4:27am

One feature conspicuously missing from ASP.NET Web API is the inability to map multiple urlencoded POST values to Web API method parameters. In this post I show a custom HttpParameterBinding that provides this highly useful functionality for your Web APIs.

16 comments
Using JSON.NET for dynamic JSON parsing
August 30, 2012 @ 5:04am

Parsing JSON dynamically rather than statically serializing into objects is becoming much more common with today's applications consuming many services of varying complexity. Sometimes you don't need to map an entire API, but only need to parse a few items out of a larger JSON response. Using JSON.NET and JObject,JArray,JValue makes it very easy to dynamically parse and read JSON data at runtime and manipulate it in a variety of different ways. Here's how.

23 comments
Using an alternate JSON Serializer in ASP.NET Web API
March 09, 2012 @ 3:30am

The default serializer in ASP.NET Web API (at least in Beta) is the DataContractJsonSerializer with all of its warts and inability to not serializer non-typed objects. In this post I'll talk about the issues and how to plug-in alternate JSON parsers to handle more complete JSON serialization in Web API.

23 comments
Using the West Wind Web Toolkit to set up AJAX and REST Services
November 03, 2011 @ 4:55am

In this post I describe how to use the West Wind Web Toolkit to create an AJAX/REST service that can serve data to a JavaScript applications with a few short steps. Then we'll look at ways to access the server side code with simple jQuery/JavaScript code and the ajaxCallMethod() helper.

10 comments
Displaying JSON in your Browser
April 01, 2011 @ 1:50am

Ever need to display JSON in your browser and finding out that it's a pain? Here are some tips on how to display JSON data without pesky download dialogs or display errors in your favorite browser.

2 comments
Custom ASP.NET Routing to an HttpHandler
March 28, 2011 @ 3:02pm

Routing support in ASP.NET 4.0 has been vastly improved, but custom routing still involves a fairly complex process of creating RouteHandlers and mapping requests properly. In this post I show an example of how to create custom routes automatically via Attribute route mapping for Http Handler endpoints.

10 comments
Allowing Access to HttpContext in WCF REST Services
January 10, 2011 @ 1:02pm

WCF REST Services do not make it easy to access all the features of the HTTP protocol, so in some situations it's just much easier to use ASP.NET compatibility to get direct access to the HttpContext object for access of all the HTTP headers and features.

8 comments
WCF REST Service Activation Errors when AspNetCompatibility is enabled
January 06, 2011 @ 2:54pm

Ran into a version problem with WCF REST Services when using on IIS and with ASP.NET Compatibility enabled. Turns out there's a potential version conflict in the system .config files that can cause this error to creep up - here's how to fix it.

1 comment
Using jQuery to POST Form Data to an ASP.NET ASMX AJAX Web Service
September 07, 2010 @ 10:40pm

ASP.NET and WCF AJAX Web Services and PageMethods natively don't accept urlencoded POST requests and so standard mechanisms for sending form POST data don't work directly with these services. However, with a few adjustments and using jQuery's .serizalizeArray() function it's possible to POST form data to ASP.NET Services and easily consume the form data.

14 comments
AspNetCompatibility in WCF Services – easy to trip up
April 12, 2010 @ 3:51pm

When using ASP.NET compatiblity in WCF REST services you'll want to be very careful in matching your configuration settings and service attributes in the correct combination or you may end up with unpleasant and hard to find ServiceActivationExceptions.

5 comments
Native JSON Parsing: What does it mean?
April 19, 2009 @ 8:20pm

The new native JSON support in new and upcoming browsers is going to improve JSON parsing performance. But there are still issues you need to deal with like the age-old JSON issue of date persistance with a JavaScript date literal. In this post I discuss various aspects of the native JSON parsers and how you can have one set of code that deals with either native parsers or the existing JSON2 interface.

16 comments
A Localization Handler to serve ASP.NET Resources to JavaScript
April 02, 2009 @ 1:08pm

Here's an implementation of an HTTP handler that can serve ASP.NET Server resources to JavaScript clients easily. The handler can provide both local and global, normalized server resources to client JavaScript pages so that you can localize resources in one place on the server. Use standard Resx resources or our custom database resource provider.

33 comments
Removing the .SVC Extension from WCF REST URLs
December 15, 2008 @ 4:27pm

One of the most frequent questions that come up when talking about WCF REST urls is how to remove the .SVC extension from the endpoint Url for a REST service. While it's not automatic, there are a couple of fairly simple solutions to this problem: Using the IIS 7 Rewrite Module or a small custom module.

15 comments
jQuery and ASP.NET Article Part 2 Posted
December 03, 2008 @ 2:26am

I've posted Part 2 of my jQuery with ASP.NET article series. Part 2 deals almost entirely with making AJAX callbacks to ASP.NET using several different mechanisms to retrieve data from the server for client side consumption. Covered are external content retrieval, same page callbacks, WCF/ASMX and a pluggable custom callback implementation that can be used with any application. Also covered is client side templating for managing HTML in one place.

63 comments
WCF REST Services and AJAX Callbacks
November 26, 2008 @ 2:10pm

I've been getting a lot of questions in response to my WCF REST session in regards of whether I'd recommend switching to WCF from ASMX services for AJAX functionality recently. WCF provides a host of new REST features, but when it comes to AJAX functionality and especially ASP.NET AJAX compatible functionality there's really nothing compelling there to require changes. In this post I look at what WCF provides for AJAX and some of the things you might watch out for.

14 comments
Debugging a WCF REST/AJAX Serialization Problem
November 04, 2008 @ 12:06am

Ran into a painful self-inflicted problem today with WCF Services for AJAX access where a service failed to serialize some data and simply returned no data of any sort. No error, no message - no HTTP content, not even headers. Here's what the problem was and the steps to debug the service to try and figure out what was wrong.

7 comments
JSON Serializers in .NET - not there yet
August 04, 2008 @ 4:00pm

.NET Framework 3.5 provides a couple of choices for JSON Serialization and Deserialization. Find out how you can use them and also some of the problems that both of these tools impose.

26 comments
West Wind Ajax Toolkit updated
July 15, 2008 @ 12:46pm

I've finally had some time to update the West Wind Ajax Toolkit to version 1.90. A number of these changes I've written about and have updated previously, but this update finalizes a number of these updates into a full release. There are a number of enhancements to the existing functionality as well as a few new helper components that I'm finding very useful these days. As always you can grab the...

6 comments
Customized Loading... Images
April 27, 2008 @ 4:13pm

Here's a cool site that provides a number of different Ajax loading images that you can use in your apps:  http://www.ajaxload.info/ What's cool about this thing versus some other sites that have many of these same images is that this is actually a dynamic app that lets you completely customize foreground and background colors including background colors which is great if you need to stick...

5 comments
Client Side Templating with jQuery
April 03, 2008 @ 4:22am

When building AJAX applications there's often the requirement to choose between client and server side rendering. Server side ASP.NET controls provide rich templating, but updating those controls on the client can be difficult. Or is it? Here's one approach using jQuery and HTML templates in markup script to dynamically create complex layout on the client without writing reams of script code.

14 comments
Rendering individual controls for AJAX Callbacks
April 01, 2008 @ 3:21am

It's quite handy to render HTML as part of AJAX callbacks and spit it back to the client. It's quite easy in fact to take advantage of ASP.NET Web Form rendering to render individual controls or compound user controls and pass them back to provide partial rendering even if you're using tools like jQuery, Prototype etc. rather than using ASP.NET AJAX.

17 comments
Firefox 3.0 XmlHttpRequest Default Content-Type change
March 12, 2008 @ 3:30am

I ran into a small problem with some of my AJAX code that's checking content-type on inbound requests from the client - it looks like FireFox 3.0 is now including the charset on the content type from the client on POST operations which if not explicitly checked for can break existing code expecting only to see a content type. Small issue, but easy to miss especially in framework code like mine that frankly should have been prepared for this...

6 comments
Embedding ASP.NET Server Variables in Client JavaScript, Part 2
February 21, 2008 @ 3:47am

This post discusses some updates to the wwScriptVariables class I talked about last week. This class provides an easy way to access server variables in client script, automatically expose ClientIDs as simply ID values and provides a mechanism for client code to send updated values back to the server to consume easily.

6 comments
Embedding ASP.NET Server Variables in Client JavaScript
February 12, 2008 @ 2:23am

Getting Server Variables embedded into a page and using them from JavaScript code can be a pain. Following Jon Galloway's post a few days ago I thought that maybe a more generic solution that doesn't rely on ASP.NET AJAX and is more generic might be useful to make the task easier and apply much broader scope. The result is an easy to use, generic class that generates a JavaScript object from key value pairs created on the server with static values or dynamic control or object properties.

24 comments
wwHoverPanel/West Wind Ajax Toolkit Updated
January 08, 2008 @ 4:12pm

I've finally had a bit of time over the holidays to roll in a few updates into my wwHoverPanel library. In the process I decided that wwHoverPanel is not really a fitting name for the library anymore since it does quite a bit more than that by now, with the hover panel operation only being a part...

6 comments
DataContractJsonSerializer in .NET 3.5
December 29, 2007 @ 9:01am

.NET 3.5 includes a new DataContractJsonSerializer that makes it real easy for serializing and deserializing .NET objects to and from JSON. This post shows code for simple serialization and deserialization as well as discussion of some of the features and limitations.

51 comments
ClientScriptProxy and JavaScript Linking In Headers
December 27, 2007 @ 7:46pm

.NET 3.5 includes a new DataContractJsonSerializer that makes it real easy for serializing and deserializing .NET objects to and from JSON. This post shows code for simple serialization and deserialization as well as discussion of some of the features and limitations.

3 comments
JSON and Date Embedding
December 24, 2007 @ 7:35am

I'm a bit mystified by various JSON implementations out there that don't seem to be dealing with dates correctly. I've been using Douglas Crockford's JSON implementation from JSON.org and originally I had to fix up the date processing so that it would work on both ends for serializing and...

19 comments
Implementing a jQuery-Calendar ASP.NET Control
October 08, 2007 @ 1:52pm

I've posted a wrapper ASP.NET around the jQuery-calendar control from Marc Garbanski. This small client side calendar control is compact, looks nice and is very easy to use and I've added an ASP.NET wrapper around it so it can more easily be more easily used with ASP.NET applications by dragging and dropping onto a form and supporting postbacks of the SelectedDate.

34 comments
WCF and JSON Services
October 04, 2007 @ 2:50am

I took a quick look today at WCF's new capability to work with JSON data. I was looking forward to having WCF services providing this functionality and there are a few cool things that work with it. It's now essentially possible to create WCF Web Services that take JSON as input and produce...

29 comments
jQuery and jQuery UI and maintaining a custom Client Library
September 22, 2007 @ 7:15pm

I've been spending some time over the last couple of days working with jQuery and a few helper components. jQuery a week ago or so released version 1.2 and a few days later a new jQuery UI library which looks to be pretty cool for a number of reasons. If you haven't looked at jQuery before I...

2 comments
wwHoverPanel AJAX Control Updated
September 12, 2007 @ 7:43pm

I've updated the wwHoverPanel library yesterday with a number of small bug fixes and a handful of new features and enhancements. Most of these are cosmetic. wwHoverPanel is a small AJAX library that I use in my internal tools and products and it provides a few core features: Simple JSON remote...

Embedding JavaScript Strings from an ASP.NET Page
July 14, 2007 @ 3:06am

I'm looking at a piece of code that's a custom control that embeds a bit of JavaScript into a page. Part of this JavaScript is generating some static string text directly into the page. I've been running this code for a while now as part of an application I'm working on with a customer. But a...

48 comments
JSONP for cross-site Callbacks
July 04, 2007 @ 1:10pm

Here's the JSONP code that uses the code I mentioned in my last post. JSONP is an unofficial protocol that allows making cross domain calls by generating script tags in the current document and expecting a result back to calls a specified callback handler. The client JavaScript code to make a JSONP...

33 comments
wwHoverPanel ASP.NET Ajax Control Update
July 03, 2007 @ 12:38am

I've just uploaded a new version of the wwHoverPanel control. wwHoverPanel is a small AJAX library that provides some useful and common functionality in an easy to use and lightweight package. The library consists of a couple of controls that provide quick client side...

1 comment
IE Lockup with createElement and appendChild
June 04, 2007 @ 8:15pm

I've been working on some client side AJAX code in a photoalbum application and I ran into a horrible situation today with IE. This innocuous code which is part of my library code (which in this case pops up an opaque overlay ontop of the page generically to render another window with an image...

4 comments
The JavaScript Dilemma
June 03, 2007 @ 3:00am

In the last year or so the Ajax lifestyle has become common practice for Web development even in the developer mainstream after a few years where the technology was primarily treated as bleeding edge technology. Today however, Ajax is drifting more and more into the mainstream of Web development...

20 comments
__doPostBack and the Back Button
May 22, 2007 @ 2:06pm

One of my Web Connection customers (but this also applies to ASP.NET) recently posted a question regarding  a page that wasn't working correctly when using the Back button. The behavior would be something like this: Go to the page Click a link that causes a __doPostBack() to occur Click the...

20 comments
Evaluating JavaScript code from C#
February 14, 2007 @ 12:10am

.NET includes support for JavaScript as a .NET language, but it's not talked about a lot. More interesting though is that you can access the JavaScript runtime from your C#/VB.NET code and it's pretty easy to do although it's not well documented. Here are a few starter scenarios...

23 comments
wwHoverPanel ASP.NET AJAX Control updated
January 30, 2007 @ 2:58am

I've updated the wwHoverPanel AJAX control to version 1.60. There are a number of new features which are mentioned in this post.

2 comments
Building a GZip JavaScript Resource Compression Module for ASP.NET
January 23, 2007 @ 2:15am

Finally got around to building a GZip script compression module for my library so I can start to quit worrying so much about script size. Here are some details on the module, how it works and how it's implemented.

16 comments
IE Opacity and DIV tags with no width
January 19, 2007 @ 4:08am

More fun inconsistencies: IE's opacity supports sucks anyway but apparently even the alpha filter doesn't work on DIV tags that don't have a width specified.

16 comments
HREF links and javascript: Navigation
January 01, 2007 @ 7:23pm

Calling JavaScript from HREF anchors can be a little tricky if you not calling external functions. There are a few things you have to watch out for with inline code and a few workarounds for letting you embed controls that have the href and javascript all in one place.

24 comments
RegisterClientScriptResource and the Type Parameter
December 26, 2006 @ 3:37pm

Usage of RegisterClientScriptResource's Type parameter can cause some unexpected behavior if you're using the all to common this.GetType() for a control. If multiple controls share the same resource be sure to use a common type or you might end up with multiple script references in your HTML

8 comments
UpdatePanels and ClientScript in custom Controls
December 12, 2006 @ 4:03am

Due to changes in the MS Ajax Beta custom controls need to deal with the ClientScript object a bit differently if the control wants to be compatible with the MS Ajax UpdatePanel. It requires using the ScriptManager when available or using ClientScript when not.

28 comments
ResourceProvider Localization Sample posted
November 05, 2006 @ 1:23pm

I’ve been talking for some time about about a localization provider I’ve been working on off and on for my session at ASP.NET Connections next week. I was finally able to post a small sample of what the provider does and what the admin interface looks like as part of my wwHoverPanel AJAX samples. The sample shows resource serving and resource editing in action.

9 comments
wwHoverPanel Update to co-exist with MS AJAX
October 25, 2006 @ 10:04pm

I’ve posted a small update to the wwHoverPanel control today that fixes a couple of small problems if used in combination with MS Ajax beta.

1 comment