作者dedek (我要快乐起来)
看板C_Sharp
标题[问题] 介面的问题
时间Sun Feb 7 21:11:33 2010
请问各位前辈帮我看我的观念(介面)对吗!
下面类别中 _headerTemplate 这个栏位是靠"ITemplate"这个介面去设定它的值
而ITemplate这个介面里面有个方法是"InstantiateIn",并且要传入一个控制项
所以我需要透过这方法才能设定_headerTemplate这栏位的值
以上的流程我的观念是对的吗?
我在asp.net中 做了以下codeing
TextBox t1 =new TextBox();
TextBox t2 = new TextBox();
t1.Text = "aa";
t2.Text = "bb";
AccordionPane adp=new AccordionPane();
adp.Header.InstantiateIn(t1);
adp.Content.InstantiateIn(t2);
===============================================
public class AccordionPane : WebControl
{
// Fields
private AccordionContentPanel _content;
private ITemplate _contentTemplate;
private AccordionContentPanel _header;
private ITemplate _headerTemplate;
// Properties
public virtual ITemplate Header { get; set; }
public virtual ITemplate Content { get; set; }
....
....
....
}
===============================================
public virtual ITemplate Header
{
get
{
return this._headerTemplate;
}
set
{
this._headerTemplate = value;
}
}
===============================================
public interface ITemplate
{
// Methods
void InstantiateIn(Control container);
}
===============================================
void InstantiateIn(Control container);
===============================================
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.37.111.230
※ 编辑: dedek 来自: 114.37.111.230 (02/07 21:13)
1F:推 horngsh:我记得jQuery有AcordianPane可用 02/08 12:55
2F:→ dedek:我想动态加入选项,所以用了这方法 02/08 14:20