Tutorial: Introduction Part 2 to AJAX in ASP.NET 2.0 and C#


V4 Ajax Tutorials
Server Intellect Cloud Hosting

Tutorial: Introduction Part 2 to AJAX in ASP.NET 2.0 and C#

This second part of an introduction to AJAX and ASP.NET shows how we can use multiple UpdatePanels and and UpdateProgress to add more interactivity to a page.

This tutorial was created with Microsoft's ASP.NET AJAX Extensions, which can be downloaded at this link

If you're looking for a really good web host, try Server Intellect - we found the setup procedure and control panel, very easy to adapt to and their IT team is awesome!

First, we start off with an AJAX-Enabled Web Application, and then we add two UpdatePanels and an UpdateProgress control to the web form:

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Label ID="Label1" runat="server"></asp:Label>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label2" runat="server"></asp:Label><br />
<asp:Button ID="Button1" runat="server" Text="Get Time Now" OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Label ID="Label3" runat="server"></asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="3000" OnTick="Timer1_Tick">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>

<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<asp:Label ID="Label4" runat="server" Text="Please Wait..Server is Processing your Request.."></asp:Label>
</ProgressTemplate>
</asp:UpdateProgress>
</form>

Server Intellect assists companies of all sizes with their hosting needs by offering fully configured server solutions coupled with proactive server management services. Server Intellect specializes in providing complete internet-ready server solutions backed by their expert 24/365 proactive support team.

We also added four labels, a button, and a timer control. Three of the labels will display a timestamp, and the fourth will display a Please Wait message to the user. Next, we add logic to the code-behind:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "Time Stamp: " + DateTime.Now.ToString();
}

protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Label2.Text = "Time Stamp: " + DateTime.Now.ToString();
}

protected void Timer1_Tick(object sender, EventArgs e)
{
Label3.Text = "Timer is ticking: " + DateTime.Now.ToString();
}
}

Server Intellect offers Windows Hosting Dedicated Servers at affordable prices. I'm very pleased!

Because this project was created with ASP.NET AJAX Extensions from Microsoft, all the nexessary tags and references in Web.config were added for us. If you do not have the AJAX Extensions installed on your copy of Visual Studio (or Visual Web Developer), or you do not have Version 2008, then your Web.config will need to look something like this:

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
<system.web.extensions>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
<!--
<jsonSerialization maxJsonLength="500">
<converters>
<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
</converters>
</jsonSerialization>
-->
<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "true|false"/>
-->
<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
writeAccessProperties attributes. -->
<!--
<profileService enabled="true"
readAccessProperties="propertyname1,propertyname2"
writeAccessProperties="propertyname1,propertyname2" />
-->
</webServices>
<!--
<scriptResourceHandler enableCompression="true" enableCaching="true" />
-->
</scripting>
</system.web.extensions>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>
</configuration>

Download Project Source - Enter your Email to be emailed a link to download the Full Source Project used in this Tutorial!



100% SPAM FREE! We will never sell or rent your email address!
 


Comments
good tutorials said:

Excellent tutorials

http://www.planetsourcecode.in

Posted May 11, 2009 11:18 AM
adjustable window screens said:

This second part of an introduction to ASP.NET AJAX and shows how WE CAN use multiple UpdatePanel and UpdateProgress and to add more interactivity to a page. Another informative post. This is a very nice blog that I will definitively come back to several more times this year!

Posted Jan 24, 2011 4:13 AM
farmacia senza ricetta said:

I waited the second part. It is definitely going to help me some time.

Posted Jan 31, 2011 3:06 PM
hawaii car hire said:

The tutorial is very informative.

Posted Feb 10, 2011 5:18 AM
Carlos Goldberg said:

Nice, very nice.

Thank you a lot!!

Posted Apr 6, 2011 8:06 PM
Dissertation Proposal said:

This diary shows that you genuinely cognize to activity the alter of your arena, dry and grouping from all over the mankind. Thanks a lot.

Posted Jul 11, 2011 6:29 AM
Louis Vuitton said:

Drive to Stem Shingles Meets Few Expectations

Posted Jul 12, 2011 10:41 PM
Hermes said:

with blue accents

Posted Jul 31, 2011 8:59 PM
Debt management said:

This information is is very useful in regards of the subject chosen for the creation of this wonderful blog entry. Thanks for sharing so productive blog.

Posted Aug 3, 2011 9:50 AM
www.outlet-louisvuitton.co.uk said:

www.outlet-louisvuitton.co.uk

Posted Aug 6, 2011 3:31 AM
disegni tatuaggi said:

It always been a pleasure to learn something new through your blogs. You really help a lot in understanding the new things. You r tutorials are always mind refreshing and useful.

Posted Aug 22, 2011 6:14 AM
Jacksonville car accident lawyer said:

The updated panels really enhance the team's project. Worker equality has prevailed.

Posted Sep 2, 2011 5:18 PM
used toyota trucks for sale said:

Let’s take a look and see what’s going on above. The OnWSRequestComplete() function is passed a URL to an RSS feed and then processes the returned XML data. The function first checks to see if the browser to see if its IE and whether or not the MSXML parser is available. If available, an XPath statement is used to locate all <item> tags within the RSS feed. For there, each item is iterated through and the correct associated <title> and <link> tags are located and processed to display each item’s data.

Posted Sep 3, 2011 5:52 PM
san antonio dentists said:

I have implement this code in my local host. But it is not working in my remote server. So what should I do? Is the any supplementary requirements of this code to run in the server?

Posted Sep 22, 2011 6:31 AM
sunglasses said:

This ajax tutorial is really a nice one. I learnt so many things from this. It was very clear to understand. Thanks a lot for the posting this site.

Posted Sep 29, 2011 8:45 AM
san antonio dental said:

Hello.. I am not using version 2008 and I tried your web config. But it's not working.. Help please...

Posted Oct 4, 2011 1:50 PM
ken griff shoes said:

This article is impressive,I hope that you will continue doing nice article like this.And do you like ken griff shoes,I have collected many beautiful griff shoes these years, the griff are so popular, I think you also can shop one ken griff shoes online store.

Posted Oct 7, 2011 5:28 AM
Belstaff Outlet said:

Do you like motorcycling and have your own motor equiments?You can come here Belstaff Outlet to find your Belstaff Jacket.Belstaff Coat can not little.If your foot is cold,Belstaff Boots is the right choice.You can buy a Belstaff Bag to hold those equipments.

Posted Oct 7, 2011 5:29 AM
designer clothing wholesale said:

It makes me feel so surprise.I never know there is such a place that I can find designer clothing wholesale.The site offers different kinds cheap designer clothing.It's really a great clothes stores with clothes wholesale.Join it now!

Posted Oct 7, 2011 5:31 AM
kiranmark said:

Thanks for your marvelous posting! I actually enjoyed reading it, you will be a great author.I will ensure that I bookmark your blog and will come back in the foreseeable future. I want to encourage that you continue your great job, have a nice weekend!

Posted Oct 9, 2011 1:26 PM
Web Designing Vizag said:

This tutorial was created with Visual Studio.NET 2008 and with Microsoft's ASP.NET AJAX Extensions, which can be downloaded as this link is installed.

Posted Oct 13, 2011 8:40 AM
kellysmith said:

In today's competetive business environment, every business is facing a cut throte competition including rental car services. <a href="http://www.bestlincolnlimo.com/dulles-limo/">Dulles car service</a> is one of the leading limousine rental car provider in Washington DC and its surroundings.

Posted Oct 19, 2011 6:19 AM
Urdu tutorial said:

Very creative work indeed. I really like this article. You have spent so much time in generating such important contents.

Posted Oct 22, 2011 5:14 AM
Antakya Biberi said:

antakya biberi zayiflama hapi antakya biber hapi

Posted Oct 23, 2011 7:42 AM
zayıflama said:

maurers zayıflama hapı termojenik zayıflama hapları zayıflama ile zayıflama bölgesel zayıflama

Posted Oct 23, 2011 7:49 AM
Web Sms Parlour said:

I have been searching for some information about it almost three hours. You helped me a lot indeed and reading this your article I have found many new and useful information about this subject.

Posted Oct 24, 2011 11:51 AM
lap band los angeles said:

it is well known that ajax is important that is why this blog is great..

Posted Nov 24, 2011 6:31 AM
catering equipment said:

But it is not working in my remote server. So what should I do? Is the any supplementary requirements of this code to run in the server?

Posted Dec 3, 2011 11:46 AM
Canada goose jas said:

data from the Alpha-Tocopherol, Beta –Carotene Cancer Prevention ) trial that smokers taking 50 mg of vitamin E each day day canadese gans day had a 35 percent reduction in prostate cancer. In Physicians Health Study II, participants took the same amount of of canada goose jassen of vitamin E as the men in the Select trial 400 IU, but it had no effect on their their

heren expedition parka

Posted Jan 3, 2012 9:46 PM
canada goose cheap said:

ans day had a 35 percent reduction in prostate cancer. In Physicians Health Study II, participants

Posted Jan 6, 2012 1:44 AM

Leave a Comment