Net-informations.com
SiteMap  | About    

ASP.NET Ajax Database Programming

Ajax introduces a new approach to WebPages that update the portion of a page by a technique called Partial-page rendering. Partial-page rendering eliminate the traditional way of loading a full postback (full page refresh) to the web server and updates only the necessary portion of a web page.

The following asp.net program shows how to connect a database from an Asp.net Ajax application. In this program we placed a DropDownList and GridView inside the UpdatePanel control area and while selecting different items from DropDownList you can see the GridView is updating without full postback to the server. Also you can notice that the page load time and data updated time with the help of Label controls

Default.aspx

  

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>Untitled Page</title>
</head>
<body>
	<form id="form1" runat="server"  >
	<div>
		<br />
		<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
		<br /><br />
	</div>
	<asp:ScriptManager ID="ScriptManager1" runat="server">
	</asp:ScriptManager>
	<asp:UpdatePanel ID="UpdatePanel1" runat="server">
		<ContentTemplate>
			<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
			onselectedindexchanged="DropDownList1_SelectedIndexChanged">
			</asp:DropDownList>
			&nbsp;&nbsp;
			<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Load Combo" />
			<br />
			<asp:GridView ID="GridView1" runat="server">
			</asp:GridView>
			<br />
			<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
		</ContentTemplate>
	</asp:UpdatePanel>
	</form>
</body>
</html>


Click the following links to see full source code

C# Source Code
VB.NET Source Code
Default.aspx.cs
Default.aspx.vb





net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.