Create simple guest book in ASP.Net and C#.Net
Sometimes we need to put guest book in our website. Suppose we don’t have any database to save the data. At that time, what can we do to save the data?
We can use simple text file to save the data.
check below code :
in page.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>GuestBook</title>
<style >
hr
{
height:1px;
background:#446791;
}
.time
{
font-size :11px;
font-family :Arial;
}
.name
{
font-family :Arial ;
font-size :11px;
font-weight :bold;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode ="Conditional" runat="server">
<Triggers >
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate >
<asp:Label ID="Label1" runat="server" Text=""></asp:Label><br />
<div style ="width :815px; height :500px; overflow :auto ">
<asp:Label ID="lblMsg" style="padding:5px" runat="server" Text="" Width ="800px" BorderColor ="Teal" BorderWidth ="1px" BorderStyle ="Solid" BackColor ="AliceBlue" ></asp:Label>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" UpdateMode ="Conditional" runat ="server" >
<Triggers >
<asp:PostBackTrigger ControlID ="btnSend" />
</Triggers>
<ContentTemplate >
<br /><br />
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate ="txtName" ErrorMessage="Enter Your Name"></asp:RequiredFieldValidator>
<br />
<asp:TextBox ID="txtMsg" TextMode ="MultiLine" Width="500px" Height="60px" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate ="txtMsg" ErrorMessage="Enter Message"></asp:RequiredFieldValidator>
<asp:Button ID="btnSend" runat="server" Text="Submit" Font-Bold ="true" onclick="btnSend_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Now download for full source code and cs code file :
Download Full Working Source Code from below links :
1. http://uploading.com/files/1832m6ee/GuestBook.zip/
Thank You.
Advertisement
