首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

IButtonControl 是个interface, 如何会有property的东西要implement 呢

2011-12-19 
IButtonControl 是个interface, 怎么会有property的东西要implement 呢?在看ProgrammingASP.NETO‘relly200

IButtonControl 是个interface, 怎么会有property的东西要implement 呢?
在看Programming   ASP.NET     O‘relly   2005的那本,在6.3.3最后一段说:

PostBackUrl   is   a   property   of   all   controls   that   implement   the   IButtonControl   interface.   This   includes   the   Button,   ImageButton,   and   LinkButton   ASP.NET   server   controls.  


可IButtonControl   是个interface,   怎么会有property的东西要implement呢?
interface   不是只包含merthod   声明的类啊?



[解决办法]
在.NET中,属性在某种程度上讲,是加了糖的方法,参考
http://blogs.msdn.com/kaevans/archive/2004/05/02/124778.aspx

using System;

namespace System.Web.UI.WebControls
{
public interface IButtonControl
{
bool CausesValidation { get; set; }
string CommandArgument { get; set; }
string CommandName { get; set; }
string PostBackUrl { get; set; }
string Text { get; set; }
string ValidationGroup { get; set; }

event EventHandler Click;
event CommandEventHandler Command;
}
}

热点排行