Lab 4: Working With ASP .NET Web Form Objectives After
Lab 4: Working With ASP .NET Web Form Objectives After
Lab 4: Working With ASP .NET Web Form Objectives After
Objectives
After completing this lab, you will be able to:
• Convert an HTML Page to a Web Form
• Adding controls to the Web Form
• Convert HTML controls to Web Form controls
3. Click Show All Files in Solution Explorer to see the code-behind page that is
created.
4. Click Save All to save the project.
5. Right-click ConvertPage.aspx in Solution Explorer, then click Build and
Browse to build the project and view the page in the Visual Studio .NET
browser. You must build the project because Visual Studio .NET needs to
compile the new code-behind page.
Lab 4.2 Adding Controls to a Web Form
Button ID cmdSubmit
Text Submit
Label1 ID lblMessage
Text Message
TextBox ID txtName
Text Name
4. View the page in HTML view. Notice that the Web Form was created with the
runat="server" attribute, and that style attributes were added to the
controls to place them on the Web Form in GridLayout mode. Also, notice
how the ID and Text properties are implemented in HTML for the different
controls.
5. Build and browse MyWebControls.aspx.
6. Enter some text in the text box and then click Submit
7. View the source of the page. Notice that the positioning of the controls is
done by using DHTML.
8. Close the source view of the page.
1. In Design view, add a Calendar Web server control onto the Web Form, and
then view the page in HTML view. Locate the HTML for the Calendar control:
<asp:Calendar id="Calendar1" runat="server"></asp:calendar>
2. Save your changes and view the page in the browser, and then view the
source of the page. Notice the entire HTML that is generated by the Calendar
control.
3. Close the source view of the page.
4. Edit the MyWebControls.aspx page and notice the properties of the Calendar
control in the Properties window.
5. Right click the Calendar control on the Web Form in Design view and select
Auto Format to show the different styles in the Calendar Auto Format
dialog box. Click Colorful 1, and then click OK.
6. Save your changes and view the page in browser again to see the new
appearance of the Calendar control.
4. To change the Label text, Go to the HTML View and between the <DIV> tag
enter the text that you want to display in the Label
The Web Form should look as follows :
(The controls aligned at the top are Web Form and the below one are HTML controls)
5. View the page in HTML view. Notice that the HTML controls have created
different tag style and code compared to Web Form controls
6. Build and browse MyWebControls.aspx.
Lab 4.3 Converting HTML controls to Web Form controls