We help IT Professionals succeed at work.

About master page code

zhshqzyc
zhshqzyc asked
on
Hello, I downloaded a project "TailspinSpyworks" from internet . The project's name is "TailspinSpyworks". The master page file is named "Site.master"  which is in the folder "Styles". I found something wrong in the master page code. Then how to modify the master page code?
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="TailspinSpyworks.SiteMaster" %>

Open in new window


Thanks
Comment
Watch Question

Jini JoseSenior .Net Developer

Commented:
i couldn't found any wrong in your line of code

did you get any errors ?
CERTIFIED EXPERT
Top Expert 2015

Commented:
Just pasting in the markup including the directives never works for me either. It never gets wired up properly.

I always create a new project, add the necessary webforms, being careful to match the names of the originals, then paste just the inside markup for each form and code behind stuff into my new webforms.
GlobaLevelProgrammer

Commented:
as mentioned above, this is just the page directive, first line at the top....did you open this in a visual studio editor?  if you click the green arrow at the top --F%, the compiler will give you errors then paste here..or give us your code...

Author

Commented:
The error is "Could load type "TailspinSpyworks.SiteMaster". Please see the attached file.
Capture14.PNG
GlobaLevelProgrammer

Commented:
Your two pages must match here:

.master:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="sample_text" %>

.master.cs:
public partial class sample_text : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

Author

Commented:
Okay. Let me upload three files. Thanks for help.
Site.Master
Site.Master.cs
Site.Master.designer.cs
GlobaLevelProgrammer

Commented:
change your directive
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="TailspinSpyworks" %>

codebehind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
//--------------------------------------------------------------------------------------------------------------------------------------------------+
// TODO: A good enhancement would be to use URL Symantecs instead ofQueryString Paramenters.
//--------------------------------------------------------------------------------------------------------------------------------------------------+
namespace TailspinSpyworks
{
    public partial class TailspinSpyworks : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (Session["UserName"] == null)
                {
                   Session["UserName"] = HttpContext.Current.User.Identity.Name;
                }
            }
        }
    }
}
CERTIFIED EXPERT
Top Expert 2015

Commented:
You're spinning your wheels unnecessarily. Just re-create the project the way I described and you will be fine.

Author

Commented:
I closed the web site and IDE. After reboot my machine and do nothing, everything is fine. Why?
Programmer
Commented:
Because it's Microsoft and the OS needs refreshed all the time for maximum Application performance.  I refresh my servers all the time

Explore More ContentExplore courses, solutions, and other research materials related to this topic.