1.Dynamic add control LinkButton
'Generate Name Link Button
Dim btnName As New LinkButton AddHandler btnName.Click, AddressOf btnDownload_Click
btnName.ID = "123"
btnName.CommandName = "name"
btnName.Attributes.Add("runat", "server")
btnName.Style.Add("text-decoration", "none")
2.Dynamic add control table and insert Link Button to TD
'Generate table
Dim table As New Table()
Dim tRow As New TableRow()
Dim tCell As New TableCell()
'Insert link button to table
tCell.Controls.Add(btnName)
tRow.Cells.Add(tCell)
table.Rows.Add(tRow)
3.Dynamic add control DIV and insert Table to DIV
'Generate div
Dim div As New HtmlGenericControl("div")
'Insert table to Div
div.Controls.Add(table)
參考資料:
http://www.allenkuo.com/EBook5/view.aspx?TreeNodeID=31&id=58
http://www.blueshop.com.tw/board/show.asp?subcde=BRD20071105235713OLJ&fumcde=
www.blueshop.com.tw/board/FUM20041006161839LRJ/BRD20060910192120K3P.html
http://www.blueshop.com.tw/board/FUM20041006161839LRJ/BRD20120828093044OHM.html
http://www.aspsnippets.com/Articles/ASPNet-Persist-Dynamic-Controls-Dynamic-Controls-disappear-after-PostBack-in-ASPNet.aspx
http://jayhsunote.blogspot.tw/2011/06/aspnet-controlusercontrolpostback.html
http://w3937.pixnet.net/blog/post/75882652-%5Bc%23%5Dasp.net-%E5%8B%95%E6%85%8B%E7%94%A2%E7%94%9F%E6%8E%A7%E5%88%B6%E9%A0%85%E7%AD%86%E8%A8%98
http://www.dotblogs.com.tw/jeff377/archive/2008/03/17/1727.aspx
http://zongnansieprogram.blogspot.tw/2013/09/c-vb-pageload-pageinit.html?spref=fb
http://www.aspsnippets.com/Articles/ASPNet-Dynamic-Controls-ViewState-Retain-state-for-dynamically-created-controls-on-PostBack.aspx
0 意見: