Practical-18
Master Page and Theme
In this practical, we will learn how to use Master Page and Theme in ASP.NET.
Step 1: Create a new ASP.NET Web Application project
- Open Visual Studio and create a new ASP.NET Web Application project.
- Choose the Empty template and click OK.
Step 2: Add a Master Page to the web form
- Right-click on the project in the Solution Explorer and select Add -> New Item.
- Choose the Master Page template and click Add.
- Name the master page file as "Site.master" and click OK.
- The master page will be added to the project.
Step 3: Design the Master Page
- Switch to the Design view of the master page.
- Design the layout of the master page by adding HTML elements, CSS styles, and placeholders for content.
- Save the master page.
Step 4: Create a Content Page
- Right-click on the project in the Solution Explorer and select Add -> New Item.
- Choose the Web Form template and click Add.
- Name the content page file as "Default.aspx" and click OK.
- The content page will be added to the project.
Step 5: Set the Master Page for the Content Page
- Open the Default.aspx file in the Solution Explorer.
- Switch to the Design view.
- In the Properties window, set the MasterPageFile property to "~/Site.master" to link the content page with the master page.
Step 6: Apply a Theme to the Web Application
- Right-click on the project in the Solution Explorer and select Add -> New Item.
- Choose the Theme template and click Add.
- Name the theme file as "CustomTheme.skin" and click OK.
- The theme file will be added to the project.
Step 7: Customize the Theme
- Open the CustomTheme.skin file in the Solution Explorer.
- Define the styles and properties for the theme using CSS and skin selectors.
- Save the theme file.
Step 8: Apply the Theme to the Master Page
- Open the Site.master file in the Solution Explorer.
- Switch to the Design view.
- In the Properties window, set the Theme property to "CustomTheme" to apply the theme to the master page.
Step 9: Run the application
- Press F5 or click the Start Debugging button to run the application.
- The web form will display the content page with the applied master page and theme.
That's it! You have successfully demonstrated the use of Master Page and Theme in ASP.NET.
Make sure to save your changes and submit this practical in your notebook.