Click here to Skip to main content
15,881,938 members
Articles / Web Development / HTML

Magic AJAX: Applying AJAX to your existing Web Pages

Rate me:
Please Sign up or sign in to vote.
4.82/5 (72 votes)
28 May 2007MIT12 min read 965.1K   2.7K   251  
How to apply AJAX technologies to your web pages without replacing ASP.NET controls and/or writing JavaScript code.
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" %>

<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
	<ajax:ajaxpanel ID="Ajaxpanel1" runat="server">
		<fieldset>
			<legend>ASP.NET 2.0 Wizard control (with validator)</legend>
			<i>An example of an ASP.NET 2.0 Wizard control using MagicAjax.<br />Entering your name in the first step is mandatory (using a RequiredFieldValidator).</i><br /><br />
			<asp:Wizard ID="Wizard1" CellPadding="7" HeaderText="Example Wizard"  SideBarStyle-VerticalAlign="Middle" runat="server" ActiveStepIndex="0" BackColor="#EFF3FB" BorderColor="#B5C7DE"
				BorderWidth="1px" Font-Names="Verdana" SideBarStyle-Width="100px" NavigationStyle-Width="300px" OnFinishButtonClick="Wizard1_FinishButtonClick">
				<StepStyle ForeColor="#333333" />
				<SideBarStyle BackColor="#507CD1"  />
				<NavigationButtonStyle BackColor="White" BorderColor="#507CD1" BorderStyle="Solid"
					BorderWidth="1px" Font-Names="Verdana"  ForeColor="#284E98" />
				<WizardSteps>
				
					<asp:WizardStep runat="server" Title="Step 1">
						<asp:Label ID="Label1" runat="server" Text="Enter your name"></asp:Label>
						<asp:TextBox ID="TextBox1" runat="server" /><br />
						<asp:RequiredFieldValidator runat="server"  Display="Static" ControlToValidate="TextBox1" ErrorMessage="Please enter your name" />
					</asp:WizardStep>
					
					<asp:WizardStep ID="WizardStep1" runat="server" Title="Step 2">
						<asp:CheckBox ID="CheckBox1" Checked="true" runat="server" Text="I like MagicAjax" />
					</asp:WizardStep>
					
					<asp:WizardStep runat="server" StepType="Finish" Title="Overview">
						<asp:Label runat="server" ID="overview" />
					</asp:WizardStep>
					
				</WizardSteps>
				<SideBarButtonStyle BackColor="#507CD1" Font-Names="Verdana" ForeColor="White" />
				<HeaderStyle BackColor="#284E98" BorderColor="#EFF3FB" BorderStyle="Solid" BorderWidth="2px"
					Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
			</asp:Wizard>
			<asp:Label runat="server" id="lblFinished" Text="Wizard is Finished!" Visible="false" BackColor="Khaki" />
		</fieldset>
  </ajax:ajaxpanel>
</asp:Content>

<script runat="server">
	private void Page_Load(object sender, EventArgs e)
	{
		if (IsPostBack)
		{
			overview.Text = string.Format("Hi {0}, {1} like MagicAjax.<br />Now click 'Finish'.", TextBox1.Text, CheckBox1.Checked ? "good to hear you" : "sorry to hear you don't");
		}
	}
	
	protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
	{
		 Wizard1.Visible = false;
		 lblFinished.Visible = true;
	}
</script>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Web Developer
Greece Greece
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions