Wednesday, March 28, 2012

Dynamic Control creation and viewstate management (client to server)

Hi all,

I am new to AJAX and this is my first port.

In my requirement i need to create set of dynamic controls (multiple instances of a custom webcontrol) to do this i am following the below steps.

    I have a user control with update panel in itI have a button "Add" to add new instance.Hidden field count to check number of dynamic instances addedHidden field to keep track of dynamic id'sRemove button to remove the instanceHandle UpdatePanel Load event to load the previous instance of controls before the control renders
    I have custom web control which inherits the ASP:Table classI override CreateChildControls method to create controls setHidden field to maintain the disabled control ids

rendering dynamic controls and its viewstate is working fine.

I am facing problem here.

I have some business logic in which the if the user selects "Yes" as the option in a RadioButtonList i am disabling few controls in the dynamically rendered sets at clientside. How to I get the controls state in the CreateChildControl method to see what was the control state using the hidden field as i am not able to get the form Posted values at this time. (Note: I know that we can use the UniqueID of the hidden field, but this will not work here as the unique id will be still the control ID unique id will be different when it renders.

So i want to know how to manage the viewstate from client and server in this scenario?

I tried to put in words as simple as possible.

Thanks for the help

- Satish

Missed to add this

When user clicks on "Yes" radio button i am saving the control id in the hidden field where in server side i can see the value in the hidden field at the server side and load the control state (either enabled or disabled). i am having problem here on how to retain the control state from clientside to the server side when it renders.

Thanks

Satish

No comments:

Post a Comment