Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday 30 December 2015

Which page is called first in asp.net c#? WebForm or Master page?


Today in Engineer's World, we are discussing a C# query faced by a developer in very easy way. Posted By- +Manish Kumar Gautam +LIVE VIAR +ASP.NET SOLUTIONS

Click imagination hunt to see latest Blogs


Which page is called first in asp.net c#? Web form or Master page?

This question is faced by every developer when they start working on Master Page.
And we start searching help from Google. And everyone ends up in the blog posted by Microsoft at https://msdn.microsoft.com/en-us/library/dct97kc3.aspx

This says the following is the sequence in which events occur when a master page is merged with a web form page:
Webform page PreInit event.
Master page controls Init event.
Webform controls Init event.
Master page Init event.
Webform page Init event.
Webform page Load event.
Master page Load event.
Master page controls Load event.
Webform page controls Load event.
Webform page PreRender event.
Master page PreRender event.
Master page controls PreRender event.
Webform page controls PreRender event.
Master page controls Unload event.
Webform page controls Unload event.
Master page Unload event.
Webform page Unload event

This sequence clarifies everything.

A Master page event called before web form events except the page load event and PreRender event.

But one question arises when did we actually see this scenario?
There are two different scenarios when you actually see this. The output also differs according to each scenario:


Related Questions:


Q-1 What will be the output of the program?

    class box
    {
        int width;
        int height;
        int length;
        int volume;
        void volume(int height, int length, int width)
        {
            volume = width * height * length;
        }
    }
    class Prameterized_method
    {
        public static void main(String[] args)
        {
            box obj = new box();
            obj.height = 1;
            obj.length = 5;
            obj.width = 5;
            obj.volume(3, 2, 1);
            Console.WriteLine(obj.volume);
            Console.ReadLine();
        }
    }

A) 1
B) 0
C) 6
D) 25

Ans.
Option(C)

Q-2 What will be the output of the given code snippet?

    class Program
    {
        static void Main(string[] args)
        {
            int x, y = 1;
            x = 10;
            if (x != 10 && x / Convert.ToInt32(0) == 0)
                Console.WriteLine(y);
            else
                Console.WriteLine(++y);
            Console.ReadLine();
        }
    }

A) 2
B) 1
C) Compile time error
D) Run time error

Ans.
Option(A).
Explanation: Both conditions for if statements are failed and hence statement after else is executed.

Click imagination hunt to see latest blogs

Keep learning and sharing…

No comments:

Post a Comment

Featured post

Think that makes you rich and richer

 Napolean said: “You can think and grow rich, but if you can be brought up like most people with work and you won't starve, this wil...