-
The configuration of ASP.NET is managed by information stored in XML-format in a configuration file (Web.Config).
-
The cache allows for improved performance of ASP.NET, as the most commonly requested pages would be served from
-
the ASP.NET cache.State management services for ASP.NET are provided by the ASP.NET state service.
-
The .NET Framework provides the Common Language Runtime (CLR) , which compiles and manages the execution of ASP.NET
-
code, and the class libraries, which offer prebuilt programmatic functionality for Web Forms, XML support, and exception handling.
-
ADO.NET provides ASP.NET with connections to databases.
3-Tier Architecture in ASP.NET with C#
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;
using System.Data.OleDb;
public class PersonDAL
{
string connStr = ConfigurationManager.ConnectionStrings["connectionstring"].ToString();
public PersonDAL()
{
}
public int Insert(string name, string address, int age)
{
OleDbConnection conn = new OleDbConnection(connStr);
conn.Open();
OleDbCommand dCmd = new OleDbCommand("insert into insertrecord values(@P,@q,@r)",conn);
try
{
dCmd.Parameters.AddWithValue("@p", name);
dCmd.Parameters.AddWithValue("@q", address);
dCmd.Parameters.AddWithValue("@r", age);
return dCmd.ExecuteNonQuery();
}
catch
{
throw;
}
finally
{
dCmd.Dispose();
conn.Close();
conn.Dispose();
}
}
}
Code for .cs file
Presentation Layer
Code for .aspx page
<%@ Page Language="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%>
<!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>
<style type="text/css">
.style1
{
width: 100%;
height: 215px;
background-color: #FFFFCC;
}
.style2
{
width: 271px;
}
.style3
{
width: 271px;
height: 44px;
}
.style4
{
height: 44px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="background-color: #008000; height: 253px;">
<table class="style1">
<tr>
<td colspan="2">
ADD RECORDS </td>
</tr>
<tr>
<td class="style2">
Name</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
 
Address </td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
Age </td>
<td class="style4">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
<td>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Save Record" />
</td>
</tr>
<tr>
<td class="style2">
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
|
No comments :
Post a Comment