ASP.NET MVC Master Pages

前端 未结 3 1765
北海茫月
北海茫月 2021-02-04 03:17

What\'s the difference between the ASP.NET Master Page, and the MVC Master Page? And the AJAX Master Page for that matter?

3条回答
  •  -上瘾入骨i
    2021-02-04 03:48

    Mostly it comes down to the default controls and inheritance.

    The AJAX Master and ASP.NET Master both inherit from System.Web.UI.MasterPage, while the MVC Master inherits from ViewMasterPage.

    Obviously, these give you slightly different controls on this - as stated by John Clayton, the ViewMasterPage exposes the Ajax/Html/Url helpers and the like, which are not available to the other MasterPages.

    Other than that, the default controls are slightly different:

    • ASP.NET Master page will have the default Form and two ContentPlaceHolder controls (one in the head, one in the form.
    • AJAX Master page also adds a ScriptManager control inside the Form control.
    • MVC Master (depending on version - I'm refering to the Beta) will just have two ContentPlaceHolder controls (in head and body).

    The "lifecycle differences" come from the Page/ViewPage, rather than the MasterPage/ViewMasterPage controls.

提交回复
热议问题