自定義控制項

2021-08-30 18:32:13 字數 4294 閱讀 7488

[size=large][color=green]最近做專案見到別人寫的乙個分頁控制項不錯,記錄一下關於路徑的問題。[/color][/size]

一、解決方案

二、新增類庫專案test

三、新增引用system.web

四、test下新增類檔案pagination.cs

五、test下新增樣式檔案pagination.css(右鍵此檔案--屬性--生成操作--嵌入的資源)

六、pagination.cs檔案下新增如下內容

using system;

using system.text.regularexpressions;

using system.web;

using system.web.ui;

using system.web.ui.htmlcontrols;

using system.web.ui.webcontrols;

//這裡是引用嵌入資源的路徑 專案名稱.資料夾.檔名

[assembly: webresource("test.css.pagination.css", "css")]

namespace common //命名空間任意

#region = 1 count =

///

/// 內容總條數

///

public int count

set

}#endregion

#region = 2 pagenum =

///

/// 每頁內容數

///

public int pagenum

set

}#endregion

#region = 3 currentpageindex =

///

/// 當前頁數

///

public int currentpageindex

else

}currentpageindex = currentpageindex < 1 ? 1 : currentpageindex;

currentpageindex = currentpageindex > pagecount ? pagecount : currentpageindex;

return currentpageindex;

}set

}#endregion

#region = 4 pagecount =

///

/// 總頁數

///

public int pagecount

}#endregion

#region = 5 cssurl =

///

/// 分頁樣式

///

public string cssurl

//專案名稱.資料夾.檔名

set

}#endregion

#region = 6 mode =

///

/// pagination的模式

///

public paginationmode mode

set}

#endregion

#region = 7 pagesname =

///

/// 分頁樣式

七、注:類檔案的命名空間任意,嵌入資源路徑要注意。

八、結構圖如下:

[img]

九、vs工具箱--新增選項卡--選擇薦--瀏覽(上面生成的dll檔案)--確定完成。

或者:將dll檔案拖曳入vs工具箱中即可。

十、拖曳使用控制項。

十一、例句如下:

//頭部自動生成引用

<%@ register assembly="test" namespace="common" tagprefix="cc1" %>

//後台**樣例

protected void page_load(object sender, eventargs e)

protected override void onprerender(eventargs e)

十二、效果圖:

[img]

十三、附件:編譯完成可用的 dll檔案

自定義控制項 自定義鐘錶

private context mcontext 畫筆 private paint mpaint 控制項的寬 private int mwidth x方向的圓心座標 private int center 鐘錶的半徑 private int mradio 圓環的寬 private int stroke...

自定義控制項

首先是以下這幾項,attribute defaultproperty指定元件的預設屬性,toolboxdata指定當從ide工具中的 工具箱中拖動自定義控制項時為它生成的預設標記 defaultproperty text toolboxdata mycontrol runat server 上面這些...

自定義控制項

新聞管理 using system using system.collections.generic using system.linq using system.web using system.web.ui using system.web.ui.webcontrols namespace ne...