When you start the application, the first page is Login.aspx. When you create an ASP.NET Web application, it adds WebForm1 as the first page of the application. You can simply change the name of this page to Login.aspx.
The Login.aspx page allows users to enter their user ID and password and checks these against the data stored in the database. If the user ID and password are found in the database table, then you let them see the available options. Otherwise they need to register as a new user.
The Login.aspx page looks like Figure 17-5. As you can see from this page, it has two TextBox controls, one Hyperlink control, five Button controls, two Label controls, and a StatusBar control. When a user comes to this page, the buttons (Post a New Job, Post a New Resume, View Jobs, and View Available Resumes) are hidden. These buttons are visible when user successfully logs in to the site.
Figure 17-5: The Login.aspx page
Listing 17-1 shows the code for the Login button click event handler. Here you simply read the values entered in the User ID and Password TextBox controls and check if these values exist in the database. As you can see from this code, you create and open a connection, read UserID and Password from the Users table by creating a SqlCommand object, and call its ExecuteReader method that creates a SqlDataReader. You use only a single row because a single row will tell you whether the user exists in the table. After, that if the user exists, you display the Post a New Job, Post a New Resume, View Jobs, and View Available Resumes buttons and hide the TextBox, Label, and Hyperlink controls. You also display a message in the StatusBar control, if the user is logged in or not.
Listing 17-1: Login Button Click Event Handler Code
Private Sub LoginBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles LoginBtn.Click ' Create and open a connection conn = New SqlConnection(connectionString) If (conn.State <> ConnectionState.Open) Then conn.Open() End If ' Construct a SQL string sql = "SELECT * FROM Users WHERE UserID='" + _ IdTextBox.Text + _ "' AND Password = '" + PassTextBox.Text + "'" ' and fill it Dim reader As SqlDataReader Dim cmd As SqlCommand = New SqlCommand(sql) cmd.Connection = conn reader = cmd.ExecuteReader(CommandBehavior.SingleRow) If (reader.Read()) Then PostJobBtn.Visible = True PostResumeBtn.Visible = True ViewJobsBtn.Visible = True ViewResumesBtn.Visible = True StatusBar.Text = "Logged In" Label1.Visible = False Label2.Visible = False IdTextBox.Visible = False PassTextBox.Visible = False NewUserLink.Visible = False LoginBtn.Visible = False Else StatusBar.Text = _ "Enter a valid User ID and Password!" End If ' Close the connection If (conn.State = ConnectionState.Open) Then conn.Close() End If End Sub
When you click the New User? Register Here HyperLink control, it simply opens the Register.aspx page. You do this by setting the NavigateUrl property of the HyperLink control as shown in Figure 17-6.
Figure 17-6: Setting the NavigateUrl property of a HyperLink control
The Post a New Job, Post a New Resume, View Available Resumes, and View Jobs button clicks simply open new Web pages: PostJob.aspx, PostResume.aspx, DisplayData.aspx, and Resumes.aspx, respectively (we'll discuss them in a moment). Listing 17-2 shows the code for these button click event handlers. As you can see, the code uses the Me.Response.Redirect method to open the new Web pages.
Listing 17-2: The Button Click Event Handlers
Private Sub PostResumeBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles PostResumeBtn.Click Me.Response.Redirect("PostResume.aspx") End Sub Private Sub ViewJobsBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles ViewJobsBtn.Click Me.Response.Redirect("DisplayData.aspx") End Sub Private Sub PostJobBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles PostJobBtn.Click Me.Response.Redirect("PostJob.aspx") End Sub Private Sub ViewResumesBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles ViewResumesBtn.Click Me.Response.Redirect("Resumes.aspx") End Sub
Now you add a new Web page called Register.aspx to the application. This page reads the user ID, password, and email address of the user. The page looks like Figure 17-7, where three TextBox controls are used to enter the user ID, password, and email address. The Register button click action saves these values to the database. The Back to Home Page button simply goes back to the Login.aspx page.
Figure 17-7: The Register.aspx page
Listing 17-3 shows the code for both of the button click event handlers. As you can see from this code, for the Register button, you construct a SqlCommand using an INSERT..INTO SQL query, add parameters and their values by reading from the TextBox controls of the page, and execute the query. This query adds a new record to the Users table of the database.
Listing 17-3: The Register.aspx Code
Private Sub RegisterBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles RegisterBtn.Click If IsValid Then ' Create a connection conn = New SqlConnection() conn.ConnectionString = connectionString 'Open connection If conn.State <> ConnectionState.Open Then conn.Open() End If ' Construct an INSERT query with parameters sql = "INSERT INTO Users(UserID, Password, Email) " & _ "VALUES (@id, @pass, @email)" cmd = New SqlCommand(sql, conn) cmd.CommandType = CommandType.Text ' Add parameters with values from text boxes cmd.Parameters.Add("@id", IdTextBox.Text) cmd.Parameters.Add("@pass", PassTextBox.Text) cmd.Parameters.Add("@email", EmailTextBox.Text) ' Execute the query Try cmd.ExecuteNonQuery() Catch exp As Exception StatusBar.Text = exp.Message.ToString() End Try ' Close connection If conn.State <> ConnectionState.Closed Then conn.Close() End If IdTextBox.Text = "" EmailTextBox.Text = "" StatusBar.Text = "Thank you registring with us." End If End Sub Private Sub BackBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles BackBtn.Click Response.Redirect("Login.aspx") End Sub
The next page you add to the application is the Contact.aspx page. This page sends a message. As you can see from Figure 17-8, you have TextBox controls for From, To, Subject, and Message. The From box takes the email address you're sending the message from; the To box takes the email address to which you are sending to the message. The Subject and Message boxes represent the title and the message body of the email, respectively. The StatusBar control displays the status of the message.
Figure 17-8: The Contact.aspx page
This page has only few lines of code for the Send Message click event handler, which is shown in Listing 17-4. As you can see from this code, you simply create a MailMessage that represents a mail message and set its From, To, Subject, and Body properties. After that we set SmtpMail.SmtpServer to the server, from which we're sending the email. Our mail server is mail5.fiberspeed.net. You must change it to your email server.
Listing 17-4: Send Message Click Event Handler
Private Sub SendMailBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles SendMailBtn.Click Dim msg As MailMessage = New MailMessage() msg.To = ToTextBox.Text msg.From = FromTextBox.Text msg.Subject = SubTextBox.Text msg.Body = MsgTextBox.Text SmtpMail.SmtpServer = "mail5.fiberspeed.net" SmtpMail.Send(msg) StatusBar.Text = "Message recieved. We will contact you soon. " End Sub
Now you add the PostJob.aspx page to the project. This page posts a new job to the job board. This page reads the information related to a job and adds to the Job table of the database. This page looks like Figure 17-9. As you can see from this page, there are five TextBox controls to read the company name, description of the job, contact person, requirements, and job details.
Figure 17-9: The PostJob.aspx page
Besides the TextBox controls, this page also has three Button controls and a StatusBar control. The Post Job button click event handler reads data from the TextBox controls and adds it to the Job database table. Listing 17-5 shows the code for the Post Job button click event handler. As you can see from this code, you simply construct a SqlCommand using an INSERT..INTO SQL query, add its parameters, and execute the query.
Listing 17-5: The Post Job Button Click Event Handler
Private Sub SaveBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles SaveBtn.Click conn = New SqlConnection() conn.ConnectionString = connectionString ' Construct an INSERT query with parameters sql = "INSERT INTO Job(Company, Contacts, Description, " & _ "Requirements, Details, PostingDate) " & _ "VALUES (@comp, @cont, @req, @des, @det, @post)" cmd = New SqlCommand(sql, conn) cmd.CommandType = CommandType.Text cmd.CommandText = sql ' Add parameters with values from text boxes cmd.Parameters.Add("@comp", CompanyTxtBox.Text) cmd.Parameters.Add("@cont", ContactsTxtBox.Text) cmd.Parameters.Add("@req", ReqTxtBox.Text) cmd.Parameters.Add("@des", DesTxtBox.Text) cmd.Parameters.Add("@det", DetailsTxtBox.Text) cmd.Parameters.Add("@post", _ SqlDbType.DateTime).Value = DateTime.Today.ToString() ' Open connection If conn.State <> ConnectionState.Open Then conn.Open() End If ' Execute the query cmd.ExecuteNonQuery() ' Close connection If conn.State <> ConnectionState.Closed Then conn.Close() End If ClearFields() StatusBar.Text = "Thank you for Job Posting" End Sub
The Reset Fields button simply clears the TextBox controls, as shown in Listing 17-6.
Listing 17-6: The Reset Fields Click Event Handler
Private Sub ClearFields() CompanyTxtBox.Text = "" ContactsTxtBox.Text = "" ReqTxtBox.Text = "" DesTxtBox.Text = "" DetailsTxtBox.Text = "" End Sub Private Sub ResetBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles ResetBtn.Click ClearFields() End Sub
The Done button click event handler redirects the browser to the Login.aspx, as shown in Listing 17-7.
Listing 17-7: The Done Button Click Event Handler
Private Sub DoneBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles DoneBtn.Click Response.Redirect("Login.aspx") End Sub
The next page you add to the project is the PostResume.aspx page. This page allows candidates to post their resumes to the Job board. This page looks like Figure 17-10. As you can see from this page, you have a TextBox control for the name, email address, resume title, address, and detailed projects handled of a candidate. The Education and Work Status combo boxes list the options for candidate's education and work status. The Willing to Relocate radio buttons allow the candidate to set the option of whether he is willing to relocate.
Figure 17-10: The PostResume.aspx page
Now let's look at the code. You add the options to the Education and Work Status combo boxes. Listing 17-8 shows the code. As you can see, the FillListBoxes methods add options to the combo boxes.
Listing 17-8: Adding Options to Post Resume Page
Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here FillListBoxes() End Sub Private Sub FillListBoxes() ' This method adds selection data to list boxes EduList.Items.Add("Master's Degree") EduList.Items.Add("Bachelor's Degree") EduList.Items.Add("Some College") EduList.Items.Add("2 Yrs Diploma") StatusList.Items.Add("US Citizen") StatusList.Items.Add("Green Card or Authorized to work") StatusList.Items.Add("H1 Visa") StatusList.Items.Add("Need Sponsorship") End Sub
The Post Resume button click adds the contents of the page to the Resumes table of the database. Listing 17-9 shows the code for this button click event handler. As you can see, you again create a SqlCommand with an INSERT..INTO SQL query, sets its parameters by reading their values from the fields filled by the user, and execute the query. This option adds a new record to the Resumes table.
Listing 17-9: The Post Resume Button Click Event Handler
Private Sub PostResumeBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles PostResumeBtn.Click conn = New SqlConnection() conn.ConnectionString = connectionString ' Construct an INSERT query with parameters sql = "INSERT INTO Resumes(Name, Email, Address, Resume, " & _ "Title, PostingDate, Education, Status, Relocate) " & _ "VALUES (@nam, @mail, @add, @res, @tit, @post, @edu, @stat, @rel)" cmd = New SqlCommand(sql, conn) cmd.CommandType = CommandType.Text ' Add parameters with values from text boxes cmd.Parameters.Add("@nam", NameTxtBox.Text) cmd.Parameters.Add("@mail", EmailTxtBox.Text) cmd.Parameters.Add("@add", AddTxtBox.Text) cmd.Parameters.Add("@res", ResumeTxtBox.Text) cmd.Parameters.Add("@tit", TitleTxtBox.Text) cmd.Parameters.Add("@post", _ SqlDbType.DateTime).Value = DateTime.Today.ToString() cmd.Parameters.Add("@edu", EduList.SelectedItem.Text.ToString) cmd.Parameters.Add("@stat", StatusList.SelectedItem.Text.ToString) If (RadioButtonList1.SelectedIndex = 1) Then cmd.Parameters.Add("@rel", "Yes") Else cmd.Parameters.Add("@rel", "No") End If ' Open connection If conn.State <> ConnectionState.Open Then conn.Open() End If ' Execute the query Try cmd.ExecuteNonQuery() Catch exp As Exception StatusBar.Text = exp.Message.ToString() End Try ' Close connection If conn.State <> ConnectionState.Closed Then conn.Close() End If ClearFields() StatusBar.Text = "Thank you for posting your resume." End Sub
The Done button click event handler simply redirects the browser to the Login.aspx page, as shown in Listing 17-10.
Listing 17-10: The Done Button Click Event Handler
Private Sub DoneBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles DoneBtn.Click Response.Redirect("Login.aspx") End Sub
The next two pages we'll discuss display the available resumes and jobs. Add two Web pages to the project called DisplayData.aspx and Resumes.aspx. The DisplayData.aspx page displays the available jobs, and the Resumes.aspx page displays the available resumes.
To display the data, you'll use the DataList control. (We discussed the DataList control and data binding in Chapter 16.) The final DisplayData.aspx page looks like Figure 17-11. On this page, the data is loaded when the page is loaded. The First Job, Previous Job, Next Job, and Last Job buttons move to the first, previous, next, and last jobs, respectively. The Home Page button redirects the browser to the Login.aspx page.
Figure 17-11: The DisplayData.aspx page
Listing 17-11 shows the complete code for the DisplayData.aspx page. As you can see from this code, you use templates to format and bind data to the template items. The tag <ItemTemplate> displays the data. (See Chapter 16 for more details about the DataList control and templates.)
Listing 17-11: DisplayData.aspx HTML View
<form method="post" runat="server"> <ASP:DATALIST style="Z-INDEX: 100; LEFT: 1px; POSITION: absolute; TOP: 115px" runat="server" ShowFooter="False" Width="494px" BorderWidth="3px" GridLines="Horizontal" CellPadding="4" BackColor="White" BorderStyle="Double" BorderColor="#336666" RepeatDirection="Horizontal" RepeatColumns="1" Height="200px"> <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#339966"> </SelectedItemStyle> <HeaderTemplate> <FONT face="verdana" size="3"><B>.NET Jobs Listing</B></FONT> </HeaderTemplate> <FooterTemplate> <FONT face="verdana" color="#996600" size="1"> DataList Control footer </FONT> </FooterTemplate> <ItemStyle HorizontalAlign="Left" ForeColor="#333333" VerticalAlign="Top" BackColor="White"> </ItemStyle> <ItemTemplate> <FONT face="verdana" size="2"> <BR> <B>Desciption ID:</B> <%# DataBinder.Eval(Container.DataItem, "Description") %> <BR> <B>Company Name:</B> <%# DataBinder.Eval(Container.DataItem, "Company") %> <BR> <B>Contact: </B> <%# DataBinder.Eval(Container.DataItem, "Contacts")%> <BR> <B>Requirements: </B> <%# DataBinder.Eval(Container.DataItem, "Requirements") %> <BR> <B>Posting Date: </B> <%# DataBinder.Eval(Container.DataItem, "PostingDate") %> <BR> <B>Job Details: </B> <%# DataBinder.Eval(Container.DataItem, "Details") %> <P> <b> <asp:HyperLink ImageUrl="" NavigateUrl="mailto:jobs@dnjobs.com" Text="Apply Now" runat="server" /> <asp:HyperLink ImageUrl="" NavigateUrl="Login.aspx" Text="Home Page" runat="server" /> </b> </FONT> </ItemTemplate> <FooterStyle ForeColor="#333333" BackColor="White"> </FooterStyle> <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#336666"> </HeaderStyle> </ASP:DATALIST></TD> <p></p> <asp:button style="Z-INDEX: 101; LEFT: 1px; POSITION: absolute; TOP: 91px" runat="server" Width="107px" BorderStyle="Groove" Font-Names="verdana" Font-Bold="True" Font-Size="8pt" Text="First Job"> </asp:button> <asp:button style="Z-INDEX: 107; LEFT: 2px; POSITION: absolute; TOP: 56px" runat="server" Width="107px" BackColor="#C0FFC0" BorderStyle="Groove" Height="26px" Font-Names="Verdana" Font-Bold="True" Font-Size="8pt" Text="Home Page"> </asp:button> <asp:button style="Z-INDEX: 103; LEFT: 108px; POSITION: absolute; TOP: 91px" runat="server" Width="115px" BorderStyle="Groove" Font-Names="verdana" Font-Bold="True" Font-Size="8pt" Text="Previous Job"> </asp:button> <asp:button style="Z-INDEX: 104; LEFT: 223px; POSITION: absolute; TOP: 91px" runat="server" Width="105px" BorderStyle="Groove" Font-Names="verdana" Font-Bold="True" Font-Size="8pt" Text="Next Job"> </asp:button> <asp:button style="Z-INDEX: 105; LEFT: 328px; POSITION: absolute; TOP: 91px" runat="server" Width="102px" BorderStyle="Groove" Font-Names="verdana" Font-Bold="True" Font-Size="8pt" Text="Last Job"> </asp:button> </form>
Now you'll write code to load and navigate the data. Before you load the data, though, you define the following variables:
Public connectionString As String = _ "Data Source=localhost;Initial Catalog=dnJobs; " & _ "user id=mahesh;password=mahesh;" Public sql As String = Nothing Public conn As SqlConnection = Nothing Public StartIndex As Integer = 0 Shared PageSize As Integer = 1 Shared CurrentIndex As Integer = 0 Shared TotalRecords As Integer = 0 Public ds As DataSet = Nothing
On the page's Load event handler, you call two methods: FillDataGrid and FillPartialData. The FullDataGrid method, shown in Listing 17-12, fills a DataSet from the Job table. On this method, you also count the total number of rows in the table and store them in the TotalRows variable, which helps you keep track of the rows.
Listing 17-12: The FillDataGrid and Page_Load Methods
Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load FillDataGrid() FillPartialData(0) End Sub Private Sub FillDataGrid() ds = New DataSet() conn = New SqlConnection() conn.ConnectionString = connectionString ' Open connection If conn.State <> ConnectionState.Open Then conn.Open() End If sql = "SELECT * FROM Resumes" Dim adapter As SqlDataAdapter = _ New SqlDataAdapter(sql, conn) adapter.Fill(ds, "Resumes") TotalRecords = ds.Tables(0).Rows.Count ' Close connection If conn.State <> ConnectionState.Closed Then conn.Close() End If End Sub
The FillPartialData method reads data from the DataSet and creates a new DataSet based on the current index of the row and the page size. In this program, you only read one row at a time. Hence, the page size is 1. After copying data into a new temporary DataSet , this method binds this new DataSet to the DataList, called ResumeList, as shown in Listing 17-13.
Listing 17-13: The FillPartialData Method
Private Sub FillPartialData(ByVal start As Integer) Dim tempDs As DataSet = ds.Clone() Dim i As Integer = 0 Dim range As Integer = start + PageSize For i = start To range - 1 Dim row As DataRow = tempDs.Tables(0).NewRow() row(0) = ds.Tables(0).Rows(i)(0) row(1) = ds.Tables(0).Rows(i)(1) row(2) = ds.Tables(0).Rows(i)(2) row(3) = ds.Tables(0).Rows(i)(3) row(4) = ds.Tables(0).Rows(i)(4) row(5) = ds.Tables(0).Rows(i)(5) row(6) = ds.Tables(0).Rows(i)(6) row(7) = ds.Tables(0).Rows(i)(7) row(8) = ds.Tables(0).Rows(i)(8) tempDs.Tables(0).Rows.Add(row) Next tempDs.Tables(0).AcceptChanges() ResumeList.DataSource = tempDs ResumeList.DataBind() End Sub
Now, on the First Job, Next Job, Previous Job, and Last Job button click event handlers, you simply call the FullPartialData method with a different index. As you can see from Listing 17-14, the First Job button click event handler passes the current index as 0, and the Last Job button click event handler passes the total rows minus the page size to read the last page. Similarly, the Next Job button click event handler passes the current index plus the page size, and the Previous Job button click event handler calls the current index minus the page size to the FillPartialData.
Listing 17-14: The FillDataGrid and Page_Load Methods
Private Sub FirstBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles FirstBtn.Click CurrentIndex = 0 FillPartialData(CurrentIndex) End Sub Private Sub PrevBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles PrevBtn.Click CurrentIndex -= PageSize If (CurrentIndex < 0) Then CurrentIndex = 0 End If FillPartialData(CurrentIndex) End Sub Private Sub NextBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles NextBtn.Click CurrentIndex += PageSize If (CurrentIndex >= TotalRecords) Then CurrentIndex = TotalRecords - PageSize End If FillPartialData(CurrentIndex) End Sub Private Sub LastBtn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles LastBtn.Click CurrentIndex = TotalRecords - PageSize FillPartialData(CurrentIndex) End Sub
The Resumes.aspx page displays available resumes. You again use a DataList control to display the resumes. The final Resumes.aspx page looks like Figure 17-12. On this page, the data is loaded when the page is loaded. The First Resume, Previous Resume, Next Resume, and Last Resume buttons move to the first, previous, next, and last resume, respectively.
Figure 17-12: The Resumes.aspx page
Listing 17-15 shows the complete code for the Resumes.aspx page. As you can see from this code, you use templates to format and bind data to the template items. The <ItemTemplate> tag displays the data. (See Chapter 16 for more details about the DataList control and templates.)
Listing 17-15: Resumes.aspx HTML View
<form method="post" runat="server"> <asp:datalist style="Z-INDEX: 100; LEFT: 14px; POSITION: absolute; TOP: 124px" runat="server" Height="255px" Width="498px" BorderWidth="1px" GridLines="Both" CellPadding="4" BackColor="White" BorderStyle="None" BorderColor="#CC9966"> <SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"> </SelectedItemStyle> <ItemStyle ForeColor="#330099" BackColor="White"> </ItemStyle> <ItemTemplate> <FONT face="verdana" size="2"> <BR> <B>Candidate Name:</B> <%# DataBinder.Eval(Container.DataItem, "Name") %> <BR> <B>Title: </B> <%# DataBinder.Eval(Container.DataItem, "Title") %> <BR> <B>Email:</B> <%# DataBinder.Eval(Container.DataItem, "Email") %> <BR> <B>Address: </B> <%# DataBinder.Eval(Container.DataItem, "Address")%> <BR> <B>Education: </B> <%# DataBinder.Eval(Container.DataItem, "Education")%> <BR> <B>Work Status: </B> <%# DataBinder.Eval(Container.DataItem, "Status")%> <BR> <B>Willing to Relocate? </B> <%# DataBinder.Eval(Container.DataItem, "Relocate")%> <BR> <B>Requirements: </B> <%# DataBinder.Eval(Container.DataItem, "PostingDate") %> <BR> <B>Resume Details: </B> <%# DataBinder.Eval(Container.DataItem, "Resume") %> /FONT> </ItemTemplate> <FooterStyle ForeColor="#330099" BackColor="#FFFFCC"> </FooterStyle> <HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"> </HeaderStyle> </asp:datalist> <asp:button style="Z-INDEX: 101; LEFT: 17px; POSITION: absolute; TOP: 101px" runat="server" BorderStyle="Groove" Width="107px" Font-Bold="True" Text="First Resume" Font-Names="verdana" Font-Size="8pt"> </asp:button> <asp:button style="Z-INDEX: 103; LEFT: 124px; POSITION: absolute; TOP: 101px" runat="server" BorderStyle="Groove" Width="127px" Font-Bold="True" Text="Previous Resume" Font-Names="verdana" Font-Size="8pt"> </asp:button> <asp:button style="Z-INDEX: 104; LEFT: 247px; POSITION: absolute; TOP: 101px" runat="server" BorderStyle="Groove" Width="105px" Font-Bold="True" Text="Next Resume" Font-Names="verdana" Font-Size="8pt"> </asp:button> <asp:button style="Z-INDEX: 105; LEFT: 352px; POSITION: absolute; TOP: 101px" runat="server" BorderStyle="Groove" Width="102px" Font-Bold="True" Text="Last Resume" Font-Names="verdana" Font-Size="8pt"> </asp:button> </form>
The code for filling data from the Resumes table to the DataList control and navigating through the resumes is the same as the code you saw on the DisplayData.aspx page for displaying a job. You just need to change the database table name from Job to Resumes in the FillDataGrid method. The rest is the same. For more details, download the source code from the Apress Web site (www.apress.com).
There is one more thing left to do. To make the application a little more interactive, you'll design one more page called dnjHeader.aspx. This page has an image and two HyperLink controls: Home Page and Contact Us. The Home Page link simply redirects the browser to the Login.aspx page, and the Contact Us link redirects the browser to the Contacts.aspx page. This page works as a header of he job board. That means every page of the job board application includes this page. Figure 17-13 shows the dnjHeader.aspx page.
Figure 17-13: The dnjHeader.aspx page
To include the dnjHeader.aspx page, you use the INCLUDE keyword. The third line in the following code includes the page to other pages. You want to make sure you change the path of the page to your application's path:
<HEAD> <title>Resumes</title> <!-- #INCLUDE Virtual="/Ch17/JobBoard/dnjHeader.aspx" --> </HEAD>
Now you're ready to run the application. When you run the application, the Login.aspx page will be the first page, which looks like Figure 17-14.
Figure 17-14: The job board
Once you register and log in to the site, you'll see job and resume options. You can test the application by posting a few resumes and jobs. After posting a few jobs and resumes, you can view the jobs and resumes by using the View Jobs and View Available Resumes buttons. The View Jobs page looks like Figure 17-15. You can use the buttons to move to the next, previous, first, and last job available in the database.
Figure 17-15: View Jobs page
The View Resumes page looks like Figure 17-16. You can use the buttons to move to the next, previous, first and last job available in the database.
Figure 17-16: The View Resumes page