Dynamic Placeholder that Saves Child Controls View State
One asp.net custom control that I am loving right now is Denis Baur’s Dynamic PlaceHolder. I’m having to do an web application that must allow for an infinite number of standard web controls and maintain state as these are entered. I went down the AJAX.NET Professional route for a minute but ran into some issues. Instead of recreating the controls on Page_INIT on every request to add a control, I’m able to add to the the new controls to the placeholder list.
Example:
Function AddProduct(Byval strPN as String)
Dim Count As Int32 = CType(ViewState(strPN & "Count_v"), Int32)
Count += 1 'increase viewstate count
Dim ddlProduct as New DropDownList
with ddlproduct
.id = "ddl" & strPN "Product" & Count.ToString()
dphP.Controls.Add(ddlproduct) 'add to dynamic placeholder
end with
ViewState(pn & "Count_v") = Count 'add back to viewstate count
End Function
Written by Tim on March 2nd, 2006 with
2 comments.
Read more articles on asp.net.
- [+] Digg: Feature this article
- [+] Del.icio.us: Bookmark this article
- [+] Furl: Bookmark this article
#1. March 29th, 2006, at 6:12 AM.
poker casino poker 642