Saturday, May 16, 2020

how to creating a website in ASP.net using master page in visual studio 2012

video for how to create website in asp.net:

 What is Master Page in ASP.NET?

- It is an ASP.NET file with the .master extension with a predefined layout that can include static text, HTML elements and server controls.

- A Master page offers a template for one or more web forms.

- It defines placeholders for the content, which can be overridden by the content pages.

- The content pages contain only content.

how to creating a website in ASP.net using master page in visual studio 2012
how to creating a website in ASP.net using master page in visual studio 2012
                                                                ASP.net page

Step 1:Create new project in Visual Studio 2012


Go to File-> New-> Web Site-> Visual C#->ASP.NET Empty Website-> Enter Application Name-> OK.

how to creating a website in ASP.net using master page in visual studio 2012

how to creating a website in ASP.net using master page in visual studio 2012


Step 2:

Create Master Page

Project name-> Add-> Add New Item->Visual C#-> Master Page->Write Master Page Name-> Add.
how to creating a website in ASP.net using master page in visual studio 2012

how to creating a website in ASP.net using master page in visual studio 2012

HomePage.master master page is created.

how to creating a website in ASP.net using master page in visual studio 2012


Add HTML code in Homepage.master page, as shown below.

Note

Here, we used contentplaceholder control.

  1. <%@ Master Language="C#" AutoEventWireup="true" CodeFile="HomePage.master.cs" Inherits="HomePage" %>  
  2.     <!DOCTYPE html>  
  3.     <html xmlns="http://www.w3.org/1999/xhtml"> head runat="server">  
  4.     <title></title>  
  5.     </head>  
  6.   
  7.     <body>  
  8.         <form id="form1" runat="server">  
  9.             <div>  
  10.                 <table border="1">  
  11.                     <tr>  
  12.                         <td colspan="2" style="text-align: center">  
  13.                             <h1>Header</h1>  
  14.                         </td>  
  15.                     </tr>  
  16.                     <tr>  
  17.                         <td style="text-align: center; height: 480px; width: 250px">  
  18.                             <h1>Menu</h1>  
  19.                         </td>  
  20.                         <td style="text-align: center; height: 480px; width: 700px">  
  21.                             <asp:ContentPlaceHolder ID="MainContentPlaceHolder1" runat="server">  
  22.                                 <h1>you can change Content here</h1>  
  23.                             </asp:ContentPlaceHolder>  
  24.                         </td>  
  25.                     </tr>  
  26.                     <tr>  
  27.                         <td colspan="2" style="text-align: center">  
  28.                             <h1>Footer</h1>  
  29.                         </td>  
  30.                     </tr>  
  31.                 </table>  
  32.             </div>  
  33.         </form>  
  34.     </body>  
  35.   
  36.     </html>  
Go to the design mode and you will see the image, as shown below.
how to creating a website in ASP.net using master page in visual studio 2012


Adding the Content Pages to Master Page

Master Page -> Add Content Page.
how to creating a website in ASP.net using master page in visual studio 2012


Note

  1. write your code inside Content Placeholder.See the below code.  
  2. <%@ Page Title="" Language="C#" MasterPageFile="~/HomePage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> < asp: Content ID = "Content1"  
  3. ContentPlaceHolderID = "MainContentPlaceHolder1"  
  4. runat = "Server" > < table > < tr > < th > < h1 > Student Information < /h1> < /th> < /tr> < tr > < td > < b > Name: Chetan Nargund < /b> </td > < /tr> < tr > < td > < b > College: AIT < /b> </td > < /tr> < tr > < td > < b > City: Bangalore < /b></td > < /tr> < /table> < /asp:Content>  
Output



how to creating a website in ASP.net using master page in visual studio 2012





0 Comments:

Post a Comment

Popular Posts

Recent Posts

Unordered List

Text Widget