我的GlobalCtrl.cs中代码是这样的:
using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;
using Shmzh.Components.SystemComponent;
using liyanCommon;namespace liyanCommon
{
/// <summary>
/// GlobalCtrl 的摘要说明。
/// </summary>
public class GlobalCtrl
{
private static readonly GlobalCtrl _instance = new GlobalCtrl(); private liyanCommon.TextCtrl _textCtrl = new TextCtrl(); public GlobalCtrl()
{
//
// TODO: 在此处添加构造函数逻辑
//
} public static GlobalCtrl getInstance()
{
return _instance;
} public liyanCommon.TextCtrl getTextCtrl()
{
return _textCtrl;
} public void reload(string strFilename)
{
_textCtrl = new TextCtrl();
_textCtrl.FileName = strFilename;
_textCtrl.loadText();
}
}
}
然后我在Global.asax.cs中的Application start中这样写:
protected void Application_Start(Object sender, EventArgs e)
{
GlobalCtrl.getInstance().reload("C:\\TextResource.xml");
string strTest = GlobalCtrl.getInstance().getTextCtrl().getText("FirstAudit");
} 在这里,strTest获得了一个值,到这一步没错。但我要把这个值赋给其他页面中的控件,我这样写的:
<div id="Action_FirstAudit" style="DISPLAY: inline; LEFT: 0px; TOP: 0px"><A onclick="FirstAudit()" href="#"><%= GlobalCtrl.getInstance().getTextCtrl().getText("FirstAudit")%></A> </div>
可是他提示:找不到类型或命名空间名称“GlobalCtrl”(是否缺少 using 指令或程序集引用?),请问我应该怎么解决这个问题。<%= GlobalCtrl.getInstance().getTextCtrl().getText("FirstAudit")%>,这里应该没错吧?
分不够的再加!本人急等待中
using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;
using Shmzh.Components.SystemComponent;
using liyanCommon;namespace liyanCommon
{
/// <summary>
/// GlobalCtrl 的摘要说明。
/// </summary>
public class GlobalCtrl
{
private static readonly GlobalCtrl _instance = new GlobalCtrl(); private liyanCommon.TextCtrl _textCtrl = new TextCtrl(); public GlobalCtrl()
{
//
// TODO: 在此处添加构造函数逻辑
//
} public static GlobalCtrl getInstance()
{
return _instance;
} public liyanCommon.TextCtrl getTextCtrl()
{
return _textCtrl;
} public void reload(string strFilename)
{
_textCtrl = new TextCtrl();
_textCtrl.FileName = strFilename;
_textCtrl.loadText();
}
}
}
然后我在Global.asax.cs中的Application start中这样写:
protected void Application_Start(Object sender, EventArgs e)
{
GlobalCtrl.getInstance().reload("C:\\TextResource.xml");
string strTest = GlobalCtrl.getInstance().getTextCtrl().getText("FirstAudit");
} 在这里,strTest获得了一个值,到这一步没错。但我要把这个值赋给其他页面中的控件,我这样写的:
<div id="Action_FirstAudit" style="DISPLAY: inline; LEFT: 0px; TOP: 0px"><A onclick="FirstAudit()" href="#"><%= GlobalCtrl.getInstance().getTextCtrl().getText("FirstAudit")%></A> </div>
可是他提示:找不到类型或命名空间名称“GlobalCtrl”(是否缺少 using 指令或程序集引用?),请问我应该怎么解决这个问题。<%= GlobalCtrl.getInstance().getTextCtrl().getText("FirstAudit")%>,这里应该没错吧?
分不够的再加!本人急等待中
aaa.Text = GlobalCtrl.getInstance().getTextCtrl().getText("FirstAudit");
不可以么?
比如把string strTest = GlobalCtrl.getInstance().getTextCtrl().getText("FirstAudit");
改成application["strTest"] = GlobalCtrl.getInstance().getTextCtrl().getText("FirstAudit"); 在需要的地方直接调用<%=application["名字"]%>就可以了。