Asp.net 2.0

ASP.NET 2.0 - Master Pages
It provide templates for other pages on your web site. with shared layout and functionality.

allow you to create a consistent look and behavior for all the pages

It defines placeholders for the content, which can be overridden by content pages. The output result is a combination of the master page and the content page.

The content pages contains the content you want to display.

When users request the content page, ASP.NET merges the pages to produce output that combines the layout of the master page with the content of the content page.

    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
   
  
   
  
  
      Untitled Page
      
      
  
The @ Master directive defines it as a master page.

The master page contains a placeholder tag for individual content.
The id="Head1" attribute identifies the placeholder, allowing many placeholders in the same master page.

Replies

  • Mahesh Dahale
    Mahesh Dahale
    .NET controls can be inserted into the other content page just like an into an ordinary page.

        <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="AboutUs.aspx.cs" Inherits="About_Us" Title="Untitled Page" %>
       
      
      
      
          
          
             

    About PIS

  • sarveshgupta
    sarveshgupta
    Master Pages are really helpful in cases when you have a standard frame or backdrop layout for your site that has to repeated on every page of that site.

    Create that once using a master page and use it on any number of pages as you want easily by refering to it as shown in the second code.
  • Mahesh Dahale
    Mahesh Dahale
    The Page.IsPostBack Property
    It runs EVERY time the page is loaded
    you can use the Page.IsPostBack property.
    If you want to execute the code in the Page_Load subroutine only the FIRST time the page is loaded
    If the Page.IsPostBack property is false, the page is loaded for the first time, if it is true, the page is posted back to the server
    [COLOR=blue]Sub[/COLOR] Page_Load
        [COLOR=blue]If[/COLOR] [COLOR=blue]Not[/COLOR] IsPostBack
                     Validate()
        [COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
    [COLOR=blue]End[/COLOR] [COLOR=blue]Sub[/COLOR]
    
    [COLOR=blue]private[/COLOR] [COLOR=blue]void[/COLOR] Page_Load()
    {
        [COLOR=blue]if[/COLOR] (!IsPostBack)
        {
            Validate();
        }
    }
    
  • sarveshgupta
    sarveshgupta
    Yes, IsPostBack helps to check that if the user has visited for the first time that is if it is a completely new session or the user is moving on the site or refreshing the page
  • Gurjeet Singh
    Gurjeet Singh
    what is the use of Autoeventwireup written in the first line of c sharp code.and by default it is true. ?
  • sarveshgupta
    sarveshgupta
    The ASP.NET page framework supports an automatic way to associate page events and methods.

    If the AutoEventWireup attribute of the Page directive is set to true (or if it is missing, since by default it is true), the page framework calls page events automatically, specifically the Page_Init and Page_Load methods. In that case, no explicit Handles clause or delegate is needed.

    But, in Visual Studio, if it is true, then the names of the methods must be as specified in its library otherwise it will not match and the events and methods will not be called.
    As a consequence, you should always leave AutoEventWireup set to false when working in Visual Studio.
  • Mahesh Dahale
    Mahesh Dahale
    cooldudeiet
    what is the use of Autoeventwireup written in the first line of c sharp code.and by default it is true. ?
    The ASP.NET page framework also supports an automatic way to associate page events and methods.

    The default value for AutoEventWireup is true for a C# web form, and false for a VB.NET web form.

    When AutoEventWireup is true,
    The ASP.NET runtime will automatically find and fire the method for the appropriate event. such as Page_Load() etc.
    (the ASP.NET page framework can automatically raise events.)

    If we switch to AutoEventWireup= false for a C# web form,
    there is a little extra work to do. Somewhere we need to
    explicitly wire up events.
    (you must manually hook up events to event handlers)
  • Gurjeet Singh
    Gurjeet Singh
    Thanks @mahesh,@sarvesh 😀

You are reading an archived discussion.

Related Posts

Afternoon to all! I am currently volunteering to mentor a undergraduate student in a mini-project. I am a mechanical engineer with a computer science background and she is a computer...
hello everyone 😁 i just came across this term in my text book....i know that no fine concrete would not have the fine aggregate.....but of what use is it. does...
i want to know how exactly GIS works in distributed systems, if it is centralized then how it manages or collects information of resources that are geographically disperesd and if...
Hi, Todd, hope this question qualifies, as I have no clue how to solve it I've provided you a drawing to the right to assist you in coming up with...
hi guys, i was wondering...... is work experience really necessary for MBA aspirants. i am asking this because i have seen people loose interest in further studies once they get...