Working with Strings


Now that you have set up the database software and installed the database, it's time to start writing the sample application.

To create a test project for this chapter:

  1. Launch Visual Studio .NET. (Start > All Programs > Microsoft Visual Studio .NET > Microsoft Visual Studio .NET).

  2. Select File > New > Project to bring up the New Project dialog.

  3. Under project types on the left side of the New Project window, click the Visual C# projects folder.

  4. Select the ASP.NET Web Application icon and change the name of the application to stringproject ( Figure 4.4 ).

    Figure 4.4. The sample application for this chapter will be an ASP.NETWeb application.

    graphics/04fig04.gif

  5. Visual Studio will create a new project and open WebForm1.aspx.

  6. Change the form's name to login.aspx. You do that by choosing View > Solution Explorer from the top menu bar.

  7. Right-click on WebForm1.aspx and choose properties. In the property grid change the FileName property from WebForm1.aspx to login.aspx ( Figure 4.5 ).

    Figure 4.5. The property grid gives you an easy way to change the filename for your Web page without having to go through Windows Explorer.

    graphics/04fig05.gif

  8. Create a form that looks like the form in Figure 4.6 . Obviously this is a lot of work to do by hand, so I suggest you enter the HTML directly into the editor instead. Figure 4.7 ( next page) shows the HTML necessary to create the form. To enter the HTML directly click the HTML button under the editor's window. As an alternative you could download the skeleton file for this project (see Tips below).

    Figure 4.6. The login form lets you enter information that will be used in connecting to the MySQL database. The form has five labels, four textboxes, and one button.

    graphics/04fig06.gif

    Figure 4.7 The Visual Studio form editor enables you to edit the HTML for the page directly. This HTML is the source for the form in Figure 4.6.
     <%@ Page language="c#" Codebehind=       "login.aspx.cs"       AutoEventWireup="false"       Inherits="stringproject.WebForm1"       enableViewState="False"       enableViewStateMac="False"%> <HTML>       <HEAD>          <title>WebForm1</title>       </HEAD>       <body MS_POSITIONING="GridLayout">          <form id="Form1" method="post"          runat="server">          <asp:  Button  id="btnConnect"                style="Z-INDEX: 101;                LEFT: 246px;                POSITION: absolute; TOP: 237px"                runat="server"                Text="  Connect  ">          </asp:Button>          <asp:  Label  id="lblTitle"                style="Z-INDEX: 102; LEFT: 18px;                POSITION: absolute; TOP: 20px"                runat="server"                Font-Size="X-Large">  Contact Manager  </asp:Label>          <asp:  Label  id="lblServer"                style="Z-INDEX: 103; LEFT: 25px;                POSITION: absolute; TOP: 71px"                runat="server" Width="56px"                Height="19px">  Server:  </asp:Label>          <asp:  TextBox  id="txtServer"                style="Z-INDEX: 104; LEFT: 90px;                POSITION: absolute; TOP: 69px"                runat="server" Width="226px"                Height="22px">  localhost  </asp:TextBox>          <asp:  Label  id="lblUserID"                style="Z-INDEX: 106; LEFT: 25px;                POSITION: absolute; TOP: 111px"                runat="server" Width="56px"                Height="19px">                User ID:           <asp:  TextBox  id="txtUserID"                style="Z-INDEX: 105; LEFT: 91px;                POSITION: absolute; TOP: 108px"                runat="server" Width="227"                Height="24">          </asp:TextBox>         </asp:Label>          <asp:  Label  id="lblPassword"                style="Z-INDEX: 107; LEFT: 25px;                POSITION: absolute; TOP: 150px"                runat="server" Width="56px"                Height="19px">  Password:  </asp:Label>          <asp:  TextBox  id="txtPassword"                style="Z-INDEX: 108; LEFT: 91px;                POSITION: absolute; TOP: 147px"                runat="server" Width="228"                Height="26"                TextMode="Password">          </asp:TextBox>          <asp:  Label  id="lblDatabase"                style="Z-INDEX: 109; LEFT: 25px;                POSITION: absolute; TOP: 190px"                runat="server">  Database:  </asp:Label>          <asp:  TextBox  id="txtDatabase"                style="Z-INDEX: 110; LEFT: 91px;                POSITION: absolute; TOP: 190px"                runat="server" Width="228px"                Height="26px">  csharpvqs  </asp:TextBox>          </form>       </body> </HTML> 

graphics/tick.gif Tips

  • As with the other projects in this book, building the project isn't necessary for learning the concepts in this chapter.

  • Skeletons for each project can be downloaded from Peachpit's Web site, http://www.peachpit.com/vqs/csharp.




C#
C# & VB.NET Conversion Pocket Reference
ISBN: 0596003196
EAN: 2147483647
Year: 2003
Pages: 198
Authors: Jose Mojica

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net