locked
Title page error on the master page/ RRS feed

  • Question

  • User-605499000 posted

    I had set up my master site page weeks ago and everything was fine. Today I got an error message regarding my title page.

    The error message: an object reference is required for the non static field with Page title or property Page Title.

    Below is part of the site master.  I have a content page on each aspx page that connects with the master page. Using visual studio 2017

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Bumples.SiteMaster" %>

    <!DOCTYPE html>

    <html lang="en">
    <head runat="server">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><%: Page.Title %> - Bumples</title>       *- Error is the PageTitle_*


    <asp:PlaceHolder runat="server">
    <%: Scripts.Render("~/bundles/modernizr") %>
    <webopt:bundlereference runat="server" path="~/Content/css" />
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />


    <link rel="stylesheet" type="text/css" href="Css/CloudsStyleSheet.css" />
    <link rel="stylesheet" type="text/css" href="Content/bootstrap-add.css" />


    <script type="text/javascript"></script>

    <style type="text/css">
    .auto-style1 {
    margin-top: 0px;
    }
    </style>

    </asp:PlaceHolder>

     If the error is not on the sitemaster page what should I be looking for. No errors on the other files.

    Thanks,

    Jen

    Wednesday, October 24, 2018 9:53 PM

Answers

  • User-605499000 posted

    Thank you for your help. I put the following in my SiteMaster page and it appears that it has corrected the problem.

    <%@Page Language="C#" AutoEventWIreup="false" CodeFile="Default.aspx.cs" Inherits="_Default"%>

    I went to Microsoft and studied page directives which you lead me to.  Also my other files did have page problems that were taken back to the site master.

    Thank you so much. I am not a programmer and I am trying to build a new web site using Wingtoys and files from my old site.  Big learning experience and I respect all of you programmers even more.

    Thanks, Jen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 25, 2018 6:30 PM

All replies

  • User-1716253493 posted

    Have you set the page title in page directive?

    Title = "The Title" 

    Thursday, October 25, 2018 1:55 AM
  • User-893317190 posted

    Hi bumples18,

    This error usually occurs when  you lose reference to this(I mean this in this.Page.Title). For example,  an instance variable is referenced in a static method.

    The link below has a similar problem with yours , you could have a look.

    https://stackoverflow.com/questions/10505187/an-object-reference-is-required-for-the-non-static-field-method-or-property-s

    What's more , does the error occur when you open every child page or only when you open specific child pages?

    If it is the second case, maybe the problem is with the specific child pages.

    If it is the first case , maybe the problem  is with the master page.

    If you still couldn't find the problem,you could set the page property in your child pages and remove the <%: Page.Title %> in your master to see whether the problem is the code you have posted.

    <%@ Page Title="Page1" Language="C#" MasterPageFile="~/ExtraControls2/menu.Master" AutoEventWireup="true" CodeBehind="Page1.aspx.cs" Inherits="MyWebFormCases.ExtraControls2.Page1" %>
    

    Best regards,
    Ackerly Xu


     

    Thursday, October 25, 2018 2:22 AM
  • User-605499000 posted

    Thank you for your help. I put the following in my SiteMaster page and it appears that it has corrected the problem.

    <%@Page Language="C#" AutoEventWIreup="false" CodeFile="Default.aspx.cs" Inherits="_Default"%>

    I went to Microsoft and studied page directives which you lead me to.  Also my other files did have page problems that were taken back to the site master.

    Thank you so much. I am not a programmer and I am trying to build a new web site using Wingtoys and files from my old site.  Big learning experience and I respect all of you programmers even more.

    Thanks, Jen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 25, 2018 6:30 PM