1 Default - Aspx: Language Autoeventwireup Codefile Inherits HTML Public Xmlns Runat

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 9

1 Default.

aspx
<%@ 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></title> </head> <body> <form id="form1" runat="server"> <div> <center> <asp:Panel ID="pnl1" runat="server" Width="300px" BackColor="DarkGray" > <div><asp:LinkButton ID="lnkbtnBooks" runat="server" Text="Books" onclick="lnkbtnBooks_Click"></asp:LinkButton> </div> <div><asp:LinkButton ID="lnkbtnHendset" runat="server" Text="Hendsets" onclick="lnkbtnHendset_Click"></asp:LinkButton></div> <div><asp:LinkButton ID="lnkbtnDetail" runat="server" Text="Details" onclick="lnkbtnDetail_Click"></asp:LinkButton></div> <div><asp:LinkButton ID="lnkbtnRemove" runat="server" Text="Remove" onclick="lnkbtnRemove_Click"></asp:LinkButton> </div> </asp:Panel> </center> </div> </form> </body> </html> Default.aspx.cs using using using using using System; System.Collections.Generic; System.Web; System.Web.UI; System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void lnkbtnBooks_Click(object sender, EventArgs e) { Response.Redirect("Books.aspx"); } protected void lnkbtnHendset_Click(object sender, EventArgs e) { Response.Redirect("HandSets.aspx"); } protected void lnkbtnDetail_Click(object sender, EventArgs e) {

2
Response.Redirect("Details.aspx"); } protected void lnkbtnRemove_Click(object sender, EventArgs e) { Session.RemoveAll(); }

Books.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Books.aspx.cs" Inherits="Books" %> <!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></title> </head> <body> <form id="form1" runat="server"> <div> <center> <asp:Panel ID="pnl1" runat="server" Width="300px" BackColor="DarkGray" Direction="LeftToRight"> <table> <tr> <td><asp:CheckBox ID="chkBook1" runat="server" Text="C language" /> &nbsp;</td> <td><asp:Label ID="lblprc1" runat="server" Text="200"></asp:Label></td> </tr> <tr>

3
<td align="left"> <asp:CheckBox ID="chkBook2" runat="server" Text="C++" /> </td> <td> <asp:Label ID="lblprc2" runat="server" Text="300"></asp:Label> </td> </tr> <tr> <td align="left"> <asp:CheckBox ID="chkBook3" runat="server" Text="Java" /> </td> <td><asp:Label ID="lblprc3" runat="server" Text="500"></asp:Label> </td> </tr> <tr> <td align="left"> <asp:CheckBox ID="chkBook4" runat="server" Text="Asp.net" /> </td> <td> <asp:Label ID="lblprc4" runat="server" Text="1000"></asp:Label> </td> </tr> </table> <br /> <asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click" /> </asp:Panel> </center> </div> </form> </body> </html> Books.aspx.cs using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections; public partial class Books : System.Web.UI.Page { DataMember Ob = new DataMember(); ArrayList list = new ArrayList(); protected void Page_Load(object sender, EventArgs e) { } protected void btnSave_Click(object sender, EventArgs e) { if (chkBook1.Checked == true) { Ob = new DataMember(); Ob.Itemname = chkBook1.Text; Ob.price = Convert.ToDouble(lblprc1.Text); list.Add(Ob);

4
} if (chkBook2.Checked == true) { Ob = new DataMember(); Ob.Itemname = chkBook2.Text; Ob.price = Convert.ToDouble(lblprc2.Text); list.Add(Ob); } if (chkBook3.Checked == true) { Ob = new DataMember(); Ob.Itemname = chkBook3.Text; Ob.price = Convert.ToDouble(lblprc3.Text); list.Add(Ob); } if (chkBook4.Checked == true) { Ob = new DataMember(); Ob.Itemname = chkBook4.Text; Ob.price = Convert.ToDouble(lblprc4.Text); list.Add(Ob); } if (list.Count != -1) { Session["books"] = list; } } } Response.Redirect("Default.aspx");

HandSets.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="HandSets.aspx.cs" Inherits="HandSets" %> <!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></title> </head> <body> <form id="form1" runat="server"> <div> <center> <asp:Panel ID="pnl1" runat="server" Width="300px" BackColor="DarkGray" Direction="LeftToRight"> <table> <tr> <td align="left"><asp:CheckBox ID="chkHnd1" runat="server" Text="Nokia" /> &nbsp;</td> <td><asp:Label ID="lblprc1" runat="server" Text="2000"></asp:Label></td> </tr> <tr> <td align="left"> <asp:CheckBox ID="chkHnd2" runat="server" Text="Samsang" /> </td> <td> <asp:Label ID="lblprc2" runat="server" Text="3000"></asp:Label> </td> </tr> <tr> <td align="left"> <asp:CheckBox ID="chkHnd3" runat="server" Text="Sony" /> </td> <td><asp:Label ID="lblprc3" runat="server" Text="5000"></asp:Label> </td> </tr> <tr> <td align="left"> <asp:CheckBox ID="chkHnd4" runat="server" Text="Motorola" /> </td> <td> <asp:Label ID="lblprc4" runat="server" Text="4000"></asp:Label> </td> </tr> </table> <br /> <asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click" /> </asp:Panel> </center> </div> </form> </body> </html> HandSets.aspx.cs

using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections; public partial class HandSets : System.Web.UI.Page { DataMember Ob = new DataMember(); ArrayList list = new ArrayList(); protected void Page_Load(object sender, EventArgs e) { } protected void btnSave_Click(object sender, EventArgs e) { if (chkHnd1.Checked == true) { Ob = new DataMember(); Ob.Itemname = chkHnd1.Text; Ob.price = Convert.ToDouble(lblprc1.Text); list.Add(Ob); } if (chkHnd2.Checked == true) { Ob = new DataMember(); Ob.Itemname = chkHnd2.Text; Ob.price = Convert.ToDouble(lblprc2.Text); list.Add(Ob); } if (chkHnd3.Checked == true) { Ob = new DataMember(); Ob.Itemname = chkHnd3.Text; Ob.price = Convert.ToDouble(lblprc3.Text); list.Add(Ob); } if (chkHnd4.Checked == true) { Ob = new DataMember(); Ob.Itemname = chkHnd4.Text; Ob.price = Convert.ToDouble(lblprc4.Text); list.Add(Ob); } if (list.Count != -1) { Session["Hendsets"] = list; } Response.Redirect("Default.aspx"); } }

Details.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Details.aspx.cs" Inherits="Details" %> <!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></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Panel ID="pnl1" runat="server" Width="300px" BackColor="DarkGray" Direction="LeftToRight"> </asp:Panel> <asp:Button ID="btnBack" runat="server" Text="Back" onclick="btnBack_Click" /> </div> </form> </body> </html> Details.aspx.cs using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections; public partial class Details : System.Web.UI.Page { ArrayList list = new ArrayList();

8
Label Book = new Label(); Label Handsets = new Label(); DataMember Ob = new DataMember(); protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Session["Books"] != null) { list = new ArrayList(); list = (ArrayList)Session["Books"]; for (int i = 0; i < list.Count; i++) { Book = new Label(); Ob = (DataMember) list[i]; Book.Text += Ob.Itemname; Book.Text += Ob.price.ToString() + "<br/"; pnl1.Controls.Add(Book); } } if (Session["Hendsets"] != null) { list = new ArrayList(); list = (ArrayList)Session["Hendsets"]; for (int i = 0; i < list.Count; i++) { Handsets = new Label(); Ob = new DataMember(); Ob = (DataMember)list[i]; Handsets.Text += Ob.Itemname; Handsets.Text += Ob.price.ToString() + "<br/>"; pnl1.Controls.Add(Handsets); } } } } protected void btnBack_Click(object sender, EventArgs e) { Response.Redirect("Default.aspx"); } }

DataMember.cs using System; using System.Collections.Generic; using System.Web; /// <summary> /// Summary description for DataMember /// </summary> public class DataMember { public DataMember() { // // TODO: Add constructor logic here // } public string Itemname; public double price; }

You might also like