0
我有這樣一類:如何在ascx文件中調用非靜態值? (.NET框架1.1)
namespace MYSCommon
{
[Serializable]
public class Cart
{
// Methods
public Cart(){
//Code skip
}
public double Value{
//Code skip
}
}
}
我用這個方法在ASPX到呼叫時,它得到了一個錯誤:
的代碼: <%= MYSCommon.Cart.Value %>
錯誤: Compiler Error Message: CS0120: An object reference is required for the nonstatic field, method, or property 'MYSCommon.Cart.Value'
但我有另外一個是這樣的:
namespace MYSCommon
{
public class Constant
{
// Fields
public static string staticValue = "Something";
}
}
並通過:<%= MYSCommon.Constant.staticValue %>
來調用它,這是成功的。 我該如何解決它?謝謝。
我無法取回ascx後面的代碼,有沒有什麼解決辦法? – DNB5brims 2013-03-26 05:17:02