Click here to Skip to main content
15,884,425 members
Articles / Programming Languages / Java

Ajaxion - Standalone AJAX - Part 2 of 2 - C# and Java Example

Rate me:
Please Sign up or sign in to vote.
4.97/5 (34 votes)
22 Jan 2013CPOL5 min read 55.2K   1.4K   42  
An article about how to keep AJAX simple as it is and get the most out of it.
<%@ Page Language="c#" Inherits="AjaxionTest.Default" EnableViewState="False" CodeFile="Default.aspx.cs" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
	<title>Default</title>
	<!--META HTTP-EQUIV="Pragma" CONTENT="no-cache"-->
	<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
	<meta content="C#" name="CODE_LANGUAGE">
	<meta content="JavaScript" name="vs_defaultClientScript">
	<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">

	<script src="Ajaxion/js/ajaxion.js" type="text/javascript"></script>
	
	<script src="js/DefaultAspx_AjaxionEvents.js" type="text/javascript"></script>

</head>
<body bgcolor="lavender">
	<form id="Form1" style="width: 100%; position: static; height: 100%" method="post"
		runat="server">
		<table id="Table1" height="100%" cellspacing="0" cellpadding="0" width="100%" align="center"
			border="0">
			<tr>
				<td style="font-weight: bold" align="center" bgcolor="silver" height="30">
					<table id="tblStatus" cellspacing="5" cellpadding="0" border="0">
						<tr>
							<td>
								<asp:Label ID="lblMessage" runat="server" ForeColor="Red"></asp:Label></td>
							<td>
								<div id="status" style="display: inline; font-weight: bold">
									Ready</div>
								&nbsp;
							</td>
							<td>
								<img id="statusImg" style="width: 150px; height: 17px; background-color: silver"
									height="17" width="150" src="images/ready.JPG" border="1"></td>
							<td style="border-left: black thin solid">
								&nbsp;<asp:HyperLink ID="lnDragDrop" runat="server" NavigateUrl="DragDrop.aspx" Font-Bold="True"
									ForeColor="Blue"> Drag'n Drop demo</asp:HyperLink></td>
							<td style="border-left: black thin solid">
								&nbsp;
								<asp:HyperLink ID="lnControlDemo" runat="server" ForeColor="Blue" Font-Bold="True" NavigateUrl="UseWebUserCtrl.aspx"> Control demo</asp:HyperLink></td>
							<td style="border-left: black thin solid">
								&nbsp;
								<asp:HyperLink ID="lnStandaloneAjaxDemo" runat="server" ForeColor="Blue" Font-Bold="True" NavigateUrl="standaloneAjax.htm"> Standalone Ajax demo</asp:HyperLink></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td style="font-weight: bold" align="center" bgcolor="whitesmoke" height="35">
					Text:
					<asp:TextBox ID="text" runat="server" EnableViewState="False" Width="200px" BorderWidth="2px"
						BorderStyle="Inset" Height="25px"></asp:TextBox>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Text
					from ajax call:
					<asp:TextBox ID="result" runat="server" ForeColor="Black" EnableViewState="False"
						Width="200px" BorderWidth="1px" BorderStyle="Solid" Height="25px" ReadOnly="True"></asp:TextBox></td>
			</tr>
			<tr>
				<td align="center" bgcolor="whitesmoke" height="35">
					<asp:Button ID="btnShowTextAspNet" runat="server" EnableViewState="False" Width="227px"
						Text="Show Text - Asp.Net normal POST" ForeColor="#C000C0" OnClick="btnShowTextAspNet_Click">
					</asp:Button>&nbsp;&nbsp;&nbsp;&nbsp;
					<input id="btnShowTextAjaxSamePage" style="width: 199px; height: 24px" onclick="ajaxion.postUrl('Default.aspx', 'textTest', GetTextCallback)"
						type="button" value="Show Text - Ajax call this page" disabled="disabled" size="">&nbsp;
					<input id="btnShowTextAjaxOtherPage" style="width: 203px; height: 24px" onclick="ajaxion.getUrl('AjaxCallbackPage.aspx?dummy=params already', 'textTest', GetTextCallback)"
						type="button" value="Show Text - Ajax call other page"></td>
			</tr>
			<tr>
				<td align="center" bgcolor="gainsboro">
					<table id="Table2" bordercolor="silver" cellspacing="0" cellpadding="1" width="100%"
						border="1">
						<tr>
							<td align="center">
								<input id="btnXmlTest" style="width: 136px; height: 24px" onclick="ajaxion.postUrl('AjaxCallbackWs.asmx/GetXmlHtml', 'xmlTest', GetXmlHtmlCallback)"
									type="button" value="Call WS - XML Test" name="btnXmlTest"></td>
							<td align="center">
								<div id="divHost">
									Receive data here.</div>
							</td>
							<td align="center">
								<input id="btnXmlTestClear" style="width: 136px; height: 24px" onclick="ajaxion.postUrl('AjaxCallbackWs.asmx/GetXmlHtml', 'xmlTestClear', GetXmlHtmlCallback)"
									type="button" value="Clear XML Test" name="btnXmlTestClear"></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td style="font-weight: bold" align="center" bgcolor="#ffcccc" height="30">
					<input id="btnStart" style="width: 92px; height: 24px" onclick="ajaxion.postUrl('AjaxCallbackWs.asmx/GetLevel', 'showLevel', ShowLevelCallback)"
						type="button" value="Start Thread">&nbsp;&nbsp;&nbsp;<asp:TextBox ID="level" runat="server"
							Font-Bold="True" ForeColor="#0000C0" EnableViewState="False" Width="204px" BorderWidth="1px"
							BorderStyle="Solid" Height="24px" ReadOnly="True" BackColor="#E0E0E0" Font-Size="Small"></asp:TextBox>&nbsp;&nbsp;
					<input id="btnStop" style="width: 135px; height: 24px" onclick="ajaxion.postUrl('AjaxCallbackWs.asmx/ResetLevel', 'resetLevel', ResetLevelCallback)"
						type="button" value="Stop / Reset Thread"></td>
			</tr>
			<tr>
				<td style="font-weight: bold" align="center" bgcolor="lightsteelblue" height="30">
					Get image from WS:&nbsp;
					<select id="dropDown" style="width: 155px">
						<option value="HappyAccountant.jpg" selected>HappyAccountant.jpg</option>
						<option value="AjaxFlavour1.gif">AjaxFlavour1.gif</option>
						<option value="AjaxFlavour2.gif">AjaxFlavour2.gif</option>
						<option value="AjaxFlavour3.jpg">AjaxFlavour3.jpg</option>
					</select>
					&nbsp;&nbsp;&nbsp;<input id="btnAjaxWsGetImgUrl_ie6" style="width: 131px; color: red;
						height: 24px" type="button" value="Get as url (IE only)" runat="server">&nbsp;&nbsp;<input
							id="btnAjaxWsGetImgUrl" style="width: 77px; height: 24px" type="button" value="Get as url"
							name="Button1" runat="server">&nbsp;<input id="btnAjaxWsGetImgBinary" style="width: 77px;
								height: 24px" type="button" value="Get binary" runat="server">
					<input id="btnAjaxWsGetImgBina2" style="width: 112px; height: 24px; color: red;" type="button"
						value="Popup (IE only)" runat="server"></td>
			</tr>
			<tr>
				<td align="center" bgcolor="#b0c4de" height="100%">
					<img id="image" title="HappyAccountant.jpg" src="images/HappyAccountant.jpg">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

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 Code Project Open License (CPOL)


Written By
Software Developer
New Zealand New Zealand
Coder

Comments and Discussions