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.



Related articles

2 comments

Read the comments left by other users below, or:

Get your own gravatar by visiting gravatar.com poker casino975
#1. March 29th, 2006, at 6:12 AM.

poker casino poker 642

Get your own gravatar by visiting gravatar.com Casino On Net
#2. May 5th, 2006, at 10:41 AM.

Casino On Net

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> .