Lastest snippets

  • Silverlight DHTML via DOM Bridge

    The simplest way is to have a target addressable text range (any html tag with and id or name set) that we can reference and write into.
    Thu, Sep 25 2008 7:00 PM by David Kelley
  • Silverlight DOM Bridge JavaScript Injection

    For the most part this method, when added to our application object or page class, makes it so we can ‘inject’ ECMA script to our hearts content. This includes code that is executed upon evaluation so we don’t have to call out again to execute some function. There are limits to what you can do (i....
    Thu, Sep 25 2008 6:58 PM by David Kelley
  • Nested GridView

    This article explains how to make an ASP.NET Editable Nested GridView. Here I am going to explain how to provide all the features of Edit/Add/Delete/Update/Page/Sort of a GridView, and not only one GridView, but I am going to explain how to extend these features to even nested grids (GridView inside...
    Wed, Jul 30 2008 4:47 AM by Gopi Subhash
  • Code to upload Audio Files in Sql Server

    Code to upload Audio/Image Files in Sql Server
    Thu, Jul 17 2008 4:21 AM by Kaushal Parik
  • Output caching

    Caching can save you loads of time on the processing side of things, so much so that ASP.NET is rich with caching features - output caching for a specific duration is simple to use. I will use output caching that will only force the render of new markup if the value of CourseId differs from one prev...
    Mon, Jun 09 2008 5:07 PM by Granville Barnett
  • Picking out query string key-value pairs

    An incredibly common task is that of retrieving the value of a specific key passed via the URL. The appealing format of URLs is that they can be composed rather elegantly and thus are in many scenarios a good way to go for passing data between pages. To access the value of a key, simply use the Requ...
    Mon, Jun 09 2008 4:58 PM by Granville Barnett
  • Checking for post back

    One of the concepts around ASP.NET that seems a little strange at first sight is that of postback, put simply when you check for postback you are essentially asking if a control on the page has invoked communication with the server after the initial response. This doesn't apply to XMLHttpRequest's t...
    Mon, Jun 09 2008 4:52 PM by Sonu Kapoor
  • Using ASP.NET AJAX to get profile data

    This is a particularly cool way to get the profile data of a user – using the profile service exposed in ASP.NET AJAX. The profile properties can be accessed as JS based properties so the programming model is pretty consistent across VB.NET, C# and JS.
    Sat, May 10 2008 6:55 PM by Granville Barnett
  • Using XML instead of JSON as the data exchange format for a web service method

    I have seen this question asked numerous times on various forums, and while XML is larger in size than JSON and requires parsing it may still be favourable to use in certain scenarios. ASP.NET AJAX actually allows you to specify the ResponseFormat of a web services’ method – selecting the Xml option...
    Wed, May 07 2008 3:57 PM by Granville Barnett
  • Using different UpdateProgress controls for different UpdatePanel controls

    One of the scenarios you may encounter several times is when you have several UpdatePanel controls on a page, but having a generic loading animation or visual cue doesn’t really transfer to the user the correct message. For this particular scenario you can actually associate an UpdateProgress contro...
    Wed, May 07 2008 3:49 PM by Granville Barnett
  • Collection initializers

    One of my personal favourite new features in C# 3.0 is the ability to concisely initialize the items of a collection using collection initializers. One thing to note is that every item of the type of the collection you define within the curly braces calls that collections Add method. You can see th...
    Mon, May 05 2008 4:36 PM by Granville Barnett
  • Using the UpdateProgress control to provide user feedback

    With the advent and somewhat mainstream adoption of AJAX the importance of visual cues became essential. One of the things woven into the ASP.NET AJAX server controls is the UpdateProgress control that makes it very easy to provide visual cues when asynchronous operations are occurring. The followin...
    Mon, May 05 2008 4:27 PM by Granville Barnett
  • ASP.NET AJAX tracing

    A powerful tool in ASP.NET AJAX development is being able to trace key events (or events you consider key in your applications behaviour) and dumping objects and/or annotations to a standard text box. Microsoft AJAX library actually has the facilities to do this, you need only have a textarea with a...
    Mon, May 05 2008 4:16 PM by Granville Barnett
  • check out below code to upload file to FTP Server:

    Code to Transfer/upload File to FTP Server
    Tue, Apr 29 2008 4:53 AM by Kaushal Parik
  • Type Initializers in C# 3.0

    C# 3.0 offers a new syntax for instantiating an object as well as setting a bunch of initial properties and values on it. This works for regular types as well as lists and dictionaries.
    Sun, Apr 27 2008 1:28 PM by Chad Myers
  • Understanding Lambda expressions in C# 3.0

    This snippet shows the evolution of delegates in C# from 1.x to the current 3.0 version. In C# 1.x, we didn't have anonymous delegates, so you had to 1.) define the delegate, 2.) create a method that implements the delegate and 3.) create and use the delegate In C# 2.x, you could use anonymous...
    Sun, Apr 27 2008 1:19 PM by Chad Myers
  • The client unload event (MS AJAX Library)

    There may be some scenarios where you need to clean something up upon the unloading of the page. The unload event is raised when the user browses to another URL. Just like the init event you have to explicitly register the event subscription.
    Sat, Apr 26 2008 8:11 PM by Granville Barnett
  • The client init event (MS AJAX Library)

    The init event is raised after all scripts have loaded BUT befor any objects have been created. Unlike the pageLoad function that is implicitly wired to the load event you have to explicitly wire the init event up.
    Sat, Apr 26 2008 8:07 PM by Granville Barnett
  • pageLoad event of the client page lifecycle

    Just like there are several events you can hook into on the server page event lifecycle there are also a few on the client now that MS AJAX exposes - one of them is pageLoad. You don't need to explicitly subscribe to the event, rather the subscription is implicit when you define a function named pag...
    Sat, Apr 26 2008 8:03 PM by Granville Barnett
  • Calling an ASMX web service using the ScriptManager and MS AJAX library

    The below is an example of calling a traditional ASP.NET web service (ASMX) using ASP.NET AJAX and the MS AJAX Library.
    Sat, Apr 26 2008 7:56 PM by Granville Barnett
  • Calling a WCF AJAX service using the ScriptManager and MS AJAX library

    Possibly one of the best things about ASP.NET AJAX is that it takes care of the plumbing when you want to call a web service, typically it will be an ASMX service but it is just as easy to call a WCF service (.svc). The below example calls a service method GetPeople that returns a List<string>...
    Sat, Apr 26 2008 7:49 PM by Granville Barnett
  • Using $get() to locate a HTML control

    A common task in a HTML page that has a lot of interaction based JavaScript is to find a control within the DOM quickly. One of the helper functions in the MS AJAX library provides a quick and concise shorthand method for locating a control by ID - $get().
    Sat, Apr 26 2008 7:36 PM by Granville Barnett
  • Binding data to a DropDownList control

    The following is a very simple example of binding a DDL's text and value properties to an active data source.
    Sat, Apr 26 2008 7:25 PM by Granville Barnett
  • Creating a template field for a GridView

    Sometimes you will want to be a little creative in how you show data in a GridView, for this scenario you are free to create a template and use the binding syntax to bind values to a control. The following snippet is very simple – it binds the ContactName to a Label control – the addition of more vi...
    Sat, Apr 26 2008 5:11 PM by Granville Barnett
  • Altering the column names in a GridView

    By default when you hook up the GridView to a data source control the header text of each column is that of the respective data (e.g. it may be the name of the property in the database table etc). Most of the time you will want to modify this, you can do so by explicitly specifying the columns of th...
    Sat, Apr 26 2008 5:01 PM by Granville Barnett