The SQL Server Express application is still not functioning. Having problems with installation. BUT the ASP.Net/C# goal is progressing nicely. I just finished a chapter where I had to create a shopping cart. Four pages (2 ASP.Net and 2 C# pages), a database, two classes, and multiple images were provided from the author's website. I wrote and debugged the CheckOut.aspx (ASP.Net), CheckOut.aspx.cs (C#), and Customer.cs (Customer Class). I also set up validation and went a step further to provide proper email validation by searching for code on the internet:
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
I am using Murach's ASP.Net 3.5 with C# 2008 book. I really enjoy using it. I was struggling with it for awhile but as a result of just finishing a class on C++, C# is a bit similar to C++ and also similar to classic asp, using this book finally clicked with me since the author said that you need to be familiar with C# before starting the book. Leave it to me to do things backwards. : )
I think my next project will involve making a login page or using SQL in a project if I can get away without using the SQL Server I am trying to install. So I will skip around a bit in the book. I will just have to figure it out with the Internet and the two new C# books I bought from Amazon. If stuck, I can always go to Dream In Code for help.
Here are some screen shots of the project: (Click to enlarge)
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
I am using Murach's ASP.Net 3.5 with C# 2008 book. I really enjoy using it. I was struggling with it for awhile but as a result of just finishing a class on C++, C# is a bit similar to C++ and also similar to classic asp, using this book finally clicked with me since the author said that you need to be familiar with C# before starting the book. Leave it to me to do things backwards. : )
I think my next project will involve making a login page or using SQL in a project if I can get away without using the SQL Server I am trying to install. So I will skip around a bit in the book. I will just have to figure it out with the Internet and the two new C# books I bought from Amazon. If stuck, I can always go to Dream In Code for help.
Here are some screen shots of the project: (Click to enlarge)
Here is what the Visual Studio 2008 dashboard looks like: (Click to enlarge)
Here is the code for "CheckOut.aspx": <%@ Page Language="C#" AutoEventWireup="true" CodeFile="CheckOut.aspx.cs" Inherits="CheckOut" %>
<!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>Check Out</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server"
Text="Please enter the following information:"></asp:Label>
<br />
<br />
<asp:Label ID="lblFirstName" runat="server" Text="First Name:" Width="110px"
style="text-align: right"></asp:Label>
<asp:TextBox ID="txtFirstName" runat="server" Width="110px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtFirstName" Display="Dynamic"
ErrorMessage="First Name is a required field.">
</asp:RequiredFieldValidator>
<br />
<asp:Label ID="lblLastName" runat="server" Text="Last Name:" Width="110px"
style="text-align: right"></asp:Label>
<asp:TextBox ID="txtLastName" runat="server"
Width="110px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtLastName" Display="Dynamic"
ErrorMessage="Last Name is a required field."></asp:RequiredFieldValidator>
<br />
<asp:Label ID="lblEmail" runat="server" Text="Email:" style="text-align: right"
Width="110px"></asp:Label>
<asp:TextBox ID="txtEmail" runat="server"
Width="110px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtEmail" Display="Dynamic"
ErrorMessage="Email is a required field."></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="ValidEmailRegExp" runat="server"
ControlToValidate="txtEmail" Display="Dynamic"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
ErrorMessage="Please enter a valid email address"></asp:RegularExpressionValidator>
<br />
<br />
<asp:Button ID="btnContinue" runat="server" Text="Continue Shopping"
Width="166px" onclick="btnContinue_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" Width="166px"
onclick="btnCancel_Click" />
<br />
<br />
</div>
</form>
</body>
</html>
Here is the code for "CheckOut.aspx.cs": (It looks very similar to C++)
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class CheckOut : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnCancel_Click(object sender, EventArgs e)
{
Response.Redirect("Order.aspx");
txtFirstName.Text = "";
txtLastName.Text = "";
txtEmail.Text = "";
}
protected void btnContinue_Click(object sender, EventArgs e)
{
Response.Redirect("Order.aspx");
}
}
No comments:
Post a Comment