我有 baslik.aspx 页面,它使用母版页。我创建了一个 Worker.cs 文件相同的库,我想从 Worker.cs 访问 baslik.aspx 文字对象。它说空对象引用!
我的 baslik.aspx:
<%@ Page Async="true" EnableEventValidation="true" Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Baslik.aspx.cs" Inherits="F8.Imza.Baslik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
..
..
<asp:Literal runat="server" id="myBaslikLiteral">
..
</asp:Content>
baslik.aspx.cs :
namespace F8.Imza
{
public partial class Baslik : System.Web.UI.Page
{
...
...
...
}
}
我想从 Worker.cs 访问页面(运行)上的任何对象:所以我尝试...:
public partial class Worker : Baslik
{
public void ActionStart()
{
this.myBaslikLiteral.Text = "Bla bla bla";
//i can see my literal name but it is null.
}
}