.NET Discussion

.NET Issues, Problems, Code Samples, and Fixes

ASP.NET and AJAX: So Freaking Easy (Part 1: Setting Up)


So you want to add AJAX to your .NET site, eh? Guess what? You don’t need to know a lick of javascript to do it.

The easiest way to create an AJAX-enabled .NET site is to first download ASP.NET AJAX (it’s free). After you’ve got it installed, in your VS2005, go to Create New Project > (Web) > ASP.NET AJAX-Enabled Web Application and create your project.  Yep, that’s it.

Oh, how do you use it? Well, Microsoft has introduced a concept called UpdatePanels which delineate what content is getting “AJAXed.” But before you do anything, you have to add a “ScriptManager” control right under your <form runat=”server”> tag.  If you use templates or master pages, you can usually just add this there and not worry about it. Anyways, after you’ve added your script manager, go ahead and pick a section of your page you want to update without refreshing the whole page.  When you’ve done this, wrap that section in a <asp:UpdatePanel id=”yourID” runat=”server”></asp:UpdatePanel> tag.  This tells the server which section you wish to update “asynchronously”, meaning separate from the rest of the page. 

After you’ve surrounded the section with your update panel, you’ll need to include just one more tag before you’re good to go: <ContentTemplate></ContentTemplate>.  This goes after the opening <asp:UpdatePanel> tag and below the respective closing tag with all your content between it.  The reason you need this is because there are more advanced features and tags you can include within your update panel that aren’t in your content, but they aren’t necessary for just starting out.

And that’s it! Go ahead and hit your pagination or sort button inside that section and see what happens.  Pretty sick, huh?

If you have an existing application that isn’t AJAX-ready and you want to make it so, there are a few more steps you need to take in the preparation stage, but implementation is, of course, the same.  I can go into it if someone posts here that they want me to (I just did it with my site! Really simple).

Has anyone had any problems with .NET/AJAX implementation?

Advertisements

July 13, 2007 - Posted by | AJAX, ASP.NET, Tips & Tricks

9 Comments »

  1. […] in Tips & Tricks, ASP.NET at 1:02 pm by Some.Net(Guy) My last post highlighted how easy it is to implement asynchronous postbacks using ASP.NET and AJAX but […]

    Pingback by ASP.NET and AJAX: So Freaking Easy (Part 2) « .NET Discussion | July 18, 2007 | Reply

  2. […] Tricks, ASP.NET, AJAX at 6:21 pm by Some.Net(Guy) As you might have read from my first two posts (Setting Up | Triggers) in this series, Microsoft has done a great job with their AJAX toolkit, making the […]

    Pingback by ASP.NET and AJAX: So Freaking Easy (Part 3: Custom Scripts) « .NET Discussion | July 18, 2007 | Reply

  3. […] Then do whatever you need to do to update your database, set the EditIndex to -1, and call your BindGridView() subroutine. Everything should be sorted out when the “Update” link is pressed. To enhance this process, be sure to include your GridView in an AJAX UpdatePanel. […]

    Pingback by ASP.NET: GridView Update/Edit/Cancel, HyperLinkFields, and DataKey Retrieval « .NET Discussion | September 26, 2007 | Reply

    • Tranks for info.
      It works perfectly with the latest version.

      Comment by forum auto | March 31, 2012 | Reply

  4. […] and AJAX: UpdatePanelPopupExtender Is An Awesome Tool Supposing that your site is set up for ASP.NET and AJAX, adding a popup panel to any control is a snap, thanks to Raj Kaimal’s […]

    Pingback by ASP.NET and AJAX: UpdatePanelPopupExtender Is An Awesome Tool « .NET Discussion | October 31, 2007 | Reply

  5. i’m eric. joining a couple boards and looking
    forward to participating. hehe unless i get
    too distracted!

    eric

    Comment by xztheericzx | November 10, 2007 | Reply

  6. […] read my articles ASP.NET: How To Easily Reference MasterPage Members and my ASP.NET and AJAX: So Freaking Easy series for more tips on how to get yourself set up even better using […]

    Pingback by ASP.NET: How to Convert Your Site To A MasterPage Site in 3 Steps « .NET Discussion | January 11, 2008 | Reply

  7. Thank you SO much and I am being blessed by this article. I managed to try all the information that I had here on my current project and everything works wonderfully.

    I am hosting my site with asphostcentral.com, which also supports AJAX and ASP.NET and therefore, it gives me less headache. Everything also works perfectly fine on this host and I am SO much thank you.

    Comment by Stephen | August 3, 2008 | Reply

  8. you’re welcome! glad i could help 🙂 thanks for the comment

    Comment by Some.Net(Guy) | August 3, 2008 | Reply


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: