In the Previous Lab #007, we learnt about the Command Buttons. Now, we will explore how to use ASP 4.0 CheckBox Control. The CheckBox Control is suitable to get a true or false choice from the user. For Example: A CheckBox showing the text Smoker expects only one input from the user, which has two choices (Yes or No). To show the text, one should use the Text property of the CheckBox Control. When the user clicks the CheckBox Control, it will raise the CheckedChanged Event. By default, the Checkbox will not do any Postback, but it can be changed via PostBack property. In this Lab #008, we will explore about the ASP 4.0 CheckBox Control.
Here, in this example, we have two SqlDataSource Controls and they both tied to Authors table of the Pubs database. The first data source control (Marked as 1) supplies data for the grid control (Marked as 3). The second data source control (Marked as 2) supplies the data to the combo box control (Marked as 4). When a user selects a state in the combo box, the DataGrid will update the authors listed in the DataGrid.
The Navigation Controls are useful for maintaining the page hierarchy as well as the page navigation in ASP.Net. There are three navigation controls that one can use in ASP.Net 2.0 and above. These controls are:
The item marked as one shows the usage of the Menu Navigation control. The menu can be laid horizontal or vertical. In our example, the menu has the horizontal direction. Item marked as 2 in the example shows the TreeView Navigation Control and it shows the Navigational link and the hierarchical Relation between them. If you see here, the site groups the links under the country names. The items marked as 3 show the usage of the SiteMapPath Navigation Control. The path navigation control helps the user to know which page they are viewing. This is handy in a big site, and the user can know the path to that page from the top-level of the page. All these controls together express the usage of the navigational control on ASP.Net 2.0 and above.
Master Pages help in providing the consistently laid-out pages. When we switch between other pages, we can note the steady look and feel throughout the websites. Microsoft provides Master Page support from ASP.Net 2.0 onward. The Master Page is used to making the outer skeleton structure of the websites and we can see this outer skeleton as web page header, footer and sidebars with navigational elements. In this example, we will explore how to create a Master page along with other web pages.
When we start this example website, it first displays the home page. We can select a product and submit it to move to the Order Confirmation page. The order confirmation page has labels to provide order confirmation and the same page also has a link called ‘Home’ to navigate back to the homepage. From the homepage, we can navigate to the Web Admin Page where we can set the theme for the entire website. We can select a theme in the web admin page and apply that theme to the whole site (In our case it contains only three pages) by clicking the ‘apply’ button. From the web admin page, we can go to the main web page by using the home link.
All three pages use two themes named Ocean and Desert. By default, when we launch the site for the first time, we do not apply any theme. So we should go to the web admin page and from there we can apply a theme. The code behind in the web admin page uses the session variable for demo purpose. You should use application variables for real websites.