Asp.net display master page only5/10/2023 The nested master page can easily bind to the Site.master and ~/Admin folder.Copy the markup from the Site.master, add the Administration section and content pages in the ~/Admin folder.User can update the Site.master master page to include the Administration section for the links used in the application.User can add the administration specific information and links to every content page in the ~/Admin folder.The benefits of nested master page are as mentioned below: All site contents can define their own child master pages and they define the look of the content pages in an application. It helps user to create customized master page. Master pages can be nested with one master page referencing to another as the master of itself. Lbl1.Text=”Master page label=”+lbl1.Text Ī sample code for demonstrating the concept of master content page is: Lbl1=(Label)Master.FindControl(“ContentPlaceHolder1”) NContentPlaceHolder = (ContentPlaceHolder)Master.FindControl(“ContentPlaceHolder1”) The code to access values of the label control is as shown below: Label lbl1 The label control is placed inside the ContentPlaceHolder of the master page. Txt1.Text=”TextBox found in the master page” Ĭonsider another example of a label control. TextBox txt1 = ( TextBox)Master.FindControl (“masterPageTextBox”) The code snippet for accessing the textbox control is shown below: Consider that the master page has a textbox control in it. To reference a control on the master page and accessing it on the content page, FindControl method is used. The code mentioned below is used to assign the value of the public property named as Countryname from the master page to a textbox on the content page. Next, user must create a code that uses the master page public member of the Master property. The syntax to add directive is as shown below: User can add reference when they are declared as public members of the master page. This includes public properties and methods. User can write code in the content pages referring properties, methods and controls in master pages. 11.3 Accessing contents of the master page in the content page User can create content by adding content controls and mapping them to the contentplaceholder controls on the master page. It defines a title for the page to be merged with the master page. The directive page binds the content page to a specific master page. The content page binds with the respective master page. The MasterPageFile is the master file which is applied to the content page. The content pages are saved with page1.aspx extension. The directive defines as a standard page. The syntax for the content page is as shown below: The content are used for holding values of the master page placeholder control.
0 Comments
Leave a Reply. |