The next step is to add the Web Application to the solution
and build the page that will allow a user to add, update, delete, and select records
from the UserAccounts table.
1.
Right click on the OrderSystem solution and select AddàNew Project from the pop-up menu.
2.
Select ASP.NET Empty Web Application from the list of project templates.
Change the name to OrderSystemUI and click the OK button.
3.
You'll need to add a reference to the OrderSystemBLL project before
proceeding. Right click the References and select Add Reference from the
pop-up menu and click the Projects tab from the dialog. Select the
OrderSystemBLL project and then click the Add button.
4.
Next you have to add the connection string to your web.config file.
<connectionStrings>
<add name="OrderSystemEntities" connectionString=
"metadata=res://*/OrderSystemDataModel.csdl|res://*/OrderSystemDataModel.ssdl|
res://*/OrderSystemDataModel.msl;provider=System.Data.SqlClient;
provider connection string="Data Source=YOURSERVER;
Initial Catalog=OrderSystem;Integrated
security=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
</connectionStrings>
Be sure to change the Data Source to your server when
adding this to your web.config file.
5.
Now you're ready to add the web form. Right click on the OrderSystemUI
project in the Solution Explorer and select AddàNew
Item… from the pop-up menu.
6.
Select the Web Form template and change the name to Users.aspx. Click
the Add button.
7.
The HTML view of the web form should appear in Visual Studio. Add the
following code between the div tags.
<tr>
<td colspan="2">
<asp:Label runat="server" ID="lblErrorLabel"
Text="Please correct the following issues:" ForeColor="Red"
Visible="false"></asp:Label>
<asp:Label runat="server" ID="lblErrorMessages" ForeColor="Red"
Visible="false"></asp:Label>
</td>
</tr>
<tr>
<td>Select A User:</td>
<td><asp:DropDownList runat=server ID="ddlUsers" AutoPostBack="True">
</asp:DropDownList> </td>
</tr>
<tr>
<td>First Name:</td>
<td><asp:TextBox runat="server" ID="txtFirstName"></asp:TextBox></td>
</tr>
<tr>
<td>Last Name:</td>
<td><asp:TextBox runat="server" ID="txtLastName"></asp:TextBox></td>
</tr>
<tr>
<td>Inserted:</td>
<td><asp:Label runat="server" ID="lblInserted"></asp:Label> </td>
</tr>
<tr>
<td>Updated:</td>
<td><asp:Label runat="server" ID="lblUpdated"></asp:Label> </td>
</tr>
</table>
<asp:Button runat=server ID="btnSave" Text="Save" />
<asp:Button ID="btnDelete" runat="server" Text="Delete" />
This code uses an HTML table to format the controls on the
web form. If you switch to Design view the form should look like the following
image.
