public class Bull : System.Web.UI.UserControl
{
private string _strID;// 自定义属性值 MID
public string IMID
{
get
{
return _strID;
}
set
{
_strID=value;
}
}
private string _strPageSize;//自定义属性 显示个数
public string IPageSize
{
get
{
return _strPageSize;
}
set
{
_strPageSize=value;
}
}
public string _strLineTitle;//行头
public string ILineTitle
{
get
{
return _strLineTitle;
}
set
{
_strLineTitle=value;
}
}
public string IForeColor
{
set
{
DLTNews.AlternatingItemStyle.ForeColor=Color.FromName(value);
}
}
public string IBackColor
{
set
{
DLTNews.AlternatingItemStyle.BackColor=Color.FromName(value);
}
}
protected System.Web.UI.WebControls.DataList DLTNews;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
new Sql.TSqlDB().BindDataList("Psp_ShowBulletinInfoList "+IPageSize+","+IMID,DLTNews);
}
}
...
}
前台
<asp:DataList id="DLTNews" runat="server" Width="185">
<ItemStyle Height="25px"></ItemStyle>
<ItemTemplate>
<a href='../Bulletin/show.aspx?id=<%# DataBinder.Eval(Container.DataItem,"dc_id") %>' target=_blank>
<%=_strLineTitle%><%# DataBinder.Eval(Container.DataItem,"vc_Title") %>
<font class="zt6">
<%# Convert.ToDateTime(DataBinder.Eval(Container.DataItem,"dt_Date")).ToString("[yyyy年MM月dd日]") %>
</font></a>
</ItemTemplate>
</asp:DataList>
调用:
<uc1:Bull id="Bull1" runat="server" IMID="278" IPageSize="5" ILineTitle="<font color=red>◇</font>" IBackColor="#ff0000">
该例子主要演示了web自定义组件的属性定义、负值和使用。
本文地址:http://com.8s8s.com/it/it7050.htm