簡體   English   中英

Asp.Net usercontrol 代碼隱藏:從另一個用戶控件引用嵌套的 class

[英]Asp.Net usercontrol codebehind: reference nested class from another usercontrol

編輯:顯然這是 VS intellisense 中的一個小插曲。 花了我很多時間,視力。 無論如何感謝您的幫助。

我要做的是從一個代碼隱藏到另一個代碼隱藏中引用內部 class ,我設法能夠使用 @reference 和classname @ reference外部 class 。 但是我無法訪問內部 class。 所以更准確地說:

public partial class A : System.Web.UI.UserControl
{
    public class Inner
    {

    }
}

現在在另一個.ascx(.cs) 文件中:

public partial class B : System.Web.UI.UserControl
{
   somemethod()
   {
    //reference A.Inner...how?
   }
}

使用內部類的原因是我綁定到一個框架,不能添加其他東西然后two.aspx控件。

要創建內部 class,只需執行以下操作:

var inner = new A.Inner();

如果A在不同的命名空間中,則

var inner = new OtherNamespace.A.Inner();

顯然,這是 VS intellisense 中的一個小插曲。 花了我很多時間,視力。 無論如何感謝您的幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM