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.

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


A .NET, PHP, Marketing Guru authority, at least I hope I am. Reach me at tboland@gmail.com

5 thoughts on “Dynamic Placeholder that Saves Child Controls View State

  1. Pingback: order soma

Leave a Reply

Your email address will not be published. Required fields are marked *