Enable AJAX with Atlas

October 2, 2006 § Leave a comment

Start off by downloading and installing the latest CTP from the asp.net site. Watch the "Get Started with “Atlas”?" video on this page to install and setup Visual Studio to be Atlas ready. You can then watch the other videos that show how to use some neat tricks to avoid server postbacks.

For the view comments feature on my blog, I created the following:

  • A custom control (by extending System.Web.UI.WebControls.WebControl) that accepts a dataset as a property and loops through the dataset in the Render method to output the necessary html.
  • A webservice that talks to my business logic, gets the necessary data, passes it to the custom control and outputs whatever the control renders.

Let’s look at a simple example:


public class HelloControl : WebControl
      private string _text; 

      public string Text
            get { return _text; }
            set { _text = value; }

      protected override void Render(HtmlTextWriter writer)
         writer.Write("<span style='font-weight:bold;color:#dd0000'>Hello "
                       + _text + "</span>");

All this control does is given an input text, it outputs the text in bold and red.


class HelloService : WebService 
      public string SayHello(string name) 
            HelloControl c = new HelloControl(); 

            StringWriter writer = new StringWriter(); 
            HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); 


            return writer.ToString(); 

That’s it, you now have a webservice that spits out html which can then be used to fill certain sections of your web page. You can watch the "“Atlas” Enable an Existing Web Service?" video to see how to use webservices on the client side using Atlas.

Have fun!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

What’s this?

You are currently reading Enable AJAX with Atlas at vaibhavkamath.info.


%d bloggers like this: