日期:2014-05-18 浏览次数:20952 次
public abstract class MyObject
{
public abstract Control SetMyControl(Control sourceControl);
}
public class TestObject : MyObject
{
public override Control SetMyControl(Control sourceControl)
{
if (Control is TextBox) //[b]你知道你的Control是什么类型[/b]
{
TextBox textBox = (TextBox)Control;
//Your Code here
return texBox
}
else if (Control is Repeater)
{
//Your Code here
//return a repeater
}
else return null;
}
}
public class SecondTestObject : MyObject
{
public override Control SetMyControl(Control sourceControl)
{
if (Control is CheckBox) //[b]我知道我的Control是什么类型[/b]
{
CheckBox checkBox = (CheckBox)Control;
//Your Code here
return checkBox;
}
else if (Control is DataList)
{
//Your Code here
//return a DataList
}
else return null;
}
}
------解决方案--------------------
UP!!!!!