Archive for the ‘Asp.net’ Category

We’re building the new Lloyds.com

It’s now public that we’re building the new Lloyd’s of London website. The news went up on Aqueduct’s blog last week.

Progressive enhancement

This site is pretty feature rich and has been a lot of fun to put together so far. It has been very important for me to keep to good web standards and to make sure the front end is accessible to the broadest audience. We’ve used the progressive enhancement approach and built a rich interface on top of an underlying no-javascript-required base.

More info

The site is looking to launch in 2010, more info at http://www.aqueduct.co.uk/blog/2009/12/were-building-new-lloydscom.html

Example using jQuery with ASP.Net (SOAP) WebServices

I don’t know about you, but I’ve had enough of slow loading aspx pages because of the huge ScriptManager JavaScript files that are needed to be downloaded. I also don’t see why I should have to register web services through it to be able to use them in my client side code.

Once answer is to use jQuery. We can access Asp.Net web services (SOAP) removing the need for the ScriptManager on your aspx page.

Asp.Net web services either use SOAP or JSON and for this post I will show you how to access your webservice using SOAP.

This is how you can do it:

First of all I like to organise all my JavaScript in to namespaces so that it stays neat so I declare the DT object.

var DT = {}

Then because we will be using Soap I have created a useful Soap function called getEnvelope which saves having to add the envelope xml each time you want to build a request.

DT.Soap = {
  getEnvelope: function(body) {
    var soapEnv =
    "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
        <soapenv:Body> \
           " + body + " \
        </soapenv:Body> \
     </soapenv:Envelope>";
    return soapEnv;
  }
}

You can use this ws object each time you define a new webservice.

DT.ws = function(wsUrl) {
    this.wsUrl = wsUrl;
}
DT.ws.prototype = {
    wsUrl: null,
    getData: function(soapEnvelope, fnComplete, fnSuccess, fnError) {
        $.ajax({
            url: this.wsUrl,
            type: "POST",
            dataType: "xml",
            data: soapEnvelope,
            contentType: "text/xml; charset=\"utf-8\"",
            complete: fnComplete,
            success: fnSuccess,
            error: fnError
        });
    }
}

Defining a new web service would then look something like the code below. We first create a new ws object instance and then define the HelloWorld method.

DT.wsCustom = new DT.ws("wsCustom.asmx");
DT.wsCustom.HelloWorld = function(fnComplete, fnSuccess, fnError) {
    var soapEnv = DT.Soap.getEnvelope("<HelloWorld xmlns='http://yournamespace.com/'></HelloWorld>");
    this.getData(soapEnv, fnComplete, fnSuccess, fnError);
}

Finally you can use your new web service with the following code.

DT.wsCustom.HelloWorld(function(xData,textStatus){
    alert("This is the xml response: " + xData.responseXML);
});

This is just a quick start to using jQuery to access Asp.Net web services. Here is part 2 to include XSL transforms and more advanced web methods.

Hope this helps.

Test/debug a local website on windows mobile 5 emulator

I had to test an ASP.net web project I am am doing which is designed to be viewed on a windows mobile or pda. After looking all over the internet I couldn’t find much information on how to do this through one of the many emulators that are available and can be linked up with Visual Studio. So here is a step by step guide to how I did it:

Step 1 : Connection Settings

Within activesync goto File > Connection Settings

  • Tick Allow connections to one of the following and choose DMA in the dropdown.
  • Choose this computer is connected to the internet

Test a local website on windows mobile 5 emulator - Active sync connection settings

Step 2 : Install SDK and Emulator Images

  • Download Pocket PC SDK from the microsoft site
  • Download Pocket PC Emulator Images

You can simillarly install the sdk and images for the smartphones etc

Step 3 : Device Emulator Manager

Within Visual Studio run the device emulator manager from the tools menu.

Device connection manager

Right click on the emulator and choose connect

Emulator Manager Cradle

Right click on the running emulator and choose cradle.

Once you have done this the emulator will connect and try to sync with activesync. Run through the Welcome to the Pocket Pc Setup wizard with the minimal setup.

Find out what your local IP address is by doing an ipconfig at the command line then you should then be able to access a website on your local machine by going to http://localipaddress/websitevirtualdir

Hope this helps!!

jQuery StarRating Asp.Net webcontrol

Here is the jQuery Star Rating Asp.Net web control. It comes in three sections: the vb.net webcontrol, the css and the javascript. Credit and thanks to Ritesh Agrawal and the guy from PHP Letter for the jQuery and css code. I have made small modifications to the jQuery code to grab the currently selected rating from the selected radio button.

Add to delicious