bug in the placeholder control ?

M

Maruthi

Hi,
I just wanted to discuss about the wierd behavior of placeholder
control. Let me explain the scenario first.
We are building an online loan origination system using ASP.NET. On a
web form we need to provide the functionality to add bank assets/
stock assets and property assets dynamically i.e if the provided input
panels are not enough. So I have created different user controls for
each of these assets, whenever the user clicks on "add new bank
asset", I am adding a new instance of the "bank asset" user control in
the bank assets place holder. Similarly whenever they click on "add
new stock asset", I am adding a new instance of the "stock asset" user
control in the stock assets place holder. I am keeping track of the
additional stocks/ bank accounts/ properties using hidden fields
(since view state is not available in Page_Init). I am adding all
these user controls again to their corresponding place holders in the
Page_Init method. It took me a while to figure out that all these user
controls are following the same ID convention regardless of their base
class. For example if there are two additional bank assets and two
additional stock assets the corresponding generated IDs are ctrl0
,ctrl1, ctrl2, ctrl3 although they are added to different place
holders and for the same reason every time the user clicks on a "add
new" link some of the user controls dont retain their previous IDs
(therefore loose ViewState). I fixed this problem by giving my own IDs
to the user controls depending on their base class and depending on
the place holder to which they are being added to. I just thought it
would have made more sense if the user control client IDs change
depending on their place holder rather than follow a dumb generic
convention which doesnt help. Please let me know of your opinion.
thanks,
Maruthi Tanneru
 
A

Anon

I am keeping track of the
additional stocks/ bank accounts/ properties using hidden fields
(since view state is not available in Page_Init).

You don't have to do this. On the first request of your page, IsPostBack =
False, you draw your initial view. Then on subsequent postbacks you override
loadviewstate method which is only called on postbacks, call Base
LoadViewState, then draw your postback view using viewstate. LoadViewState
method happens right after init method but before the load user post back
data method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top