I am trying to link a web form to be able to access a variable on the main page. I did it until it worked. But now, when I do this, I get an error message.
Code in Site.Master
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>
Code in Site.Master.cs
public partial class Site : System.Web.UI.MasterPage
{
public string hi = "";
protected void Page_Load(object sender, EventArgs e)
{
}
}
Code in WebForm1.aspx:
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="WebForm1.aspx.cs" Inherits="WebForm1" %>
<%@ MasterType VirtualPath="~/Site.master" %>
Code in WebForm1.aspx.cs
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Master.hi="new"
}
}
When I hang over hi, I get this message
Error in Visual Studio - "You can use the navigation bar to switch contexts
Here is another image
Screenshot
If you guys could help me, it really will be great
source
share