Which page is called first in asp.net c#? Web form or Master page?
Which page is called first in asp.net c#? Web form or Master page?
One such scenario is - Suppose you have a master page and a nested web form page. In your master page, you write some piece of code. Like, you add a label control and write its Text property as “Master Page Load” with Red color.
Note: We haven’t written any code in the code-behind for any page (neither in master nor in web form page).
Code that we write on the master page.
Practical Implementation:
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Master Page Load"ForeColor="Red"></asp:Label>
<br />
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
In the same manner, you add a label control and write its Text property as “Content Page Load” with Red color.
Code that we write on web form page
Practical Implementation:
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">
<asp:Label ID="Label1" runat="server" Text="Content Page Load"ForeColor="Red"></asp:Label>
<br />
</asp:Content>
Now, the question arises
Which page label control is called first? Is it the Default.aspx or MasterPage.master?
Let’s run and check
Comments
Post a Comment