jru*_*ell 11 asp.net web-controls
我很好奇为什么只有一些System.Web.UI.WebControl控件在具有相同的接口属性时实现某些接口.
例如,有很多控件具有Text属性,但只有以下工具ITextControl:
(TextBox和ListControl实际上实现了IEditableTextControl,它实现了ITextControl)
TableCell,Button,HyperLink等不是这样我必须编写这样的代码
ITextControl textControl = control as ITextControl;
TableCell tableCell = control as TableCell;
if (textControl != null)
{
textControl.Text = value;
}
else if (tableCell != null)
{
tableCell.Text = value;
}
Run Code Online (Sandbox Code Playgroud)
而不是这个
control.Text = value;
Run Code Online (Sandbox Code Playgroud)
这是设计决定还是疏忽?
| 归档时间: |
|
| 查看次数: |
1102 次 |
| 最近记录: |