2012-08-02 33 views
0

我們可以使用控件適配器更改ASP.NET控件的輸出呈現。現在我想知道,是否可以通過ASP.NET中的控件適配器更改用戶控件呈現?順便說一下,我的頁面中有幾個用戶控件,我不想爲它們執行相同的操作。在ASP.NET中使用用戶控件的控件適配器

回答

0

是的,你可以,但你必須定義你的控件孩子的公衆在您的用戶控制

(Associate public on child controls in order to access from your adapter) 

public class UserControlSample : userControl 
{ 
    public TextBox TextBoxWrapper 
    { 
     get 
     { 
     return MyTextBox; 
     } 
     set 
     { 
     MyTextBox = value; 
     } 
    } 
} 


//Access from adapter 
UserControlSample.TextBoxWrapper.Text 
UserControlSample.TextBoxWrapper.Id 
..... 
+0

如何訪問到子控件的適配器? – mshirdel 2012-08-02 12:14:34

+0

對不起,我添加了代碼 – 2012-08-02 12:24:36