Values in UpdateObjectArgs vs Request.Form

Values in UpdateObjectArgs vs Request.Form

Old forum URL: forums.lhotka.net/forums/t/8522.aspx


tiago.santos posted on Friday, February 12, 2010

I've notice that the values in UpdateObjectArgs aren't the same that those that are in Request.Form.

For example, if I have some controls that bind to some properties, inside a <asp:Panel. And if the Panel is not Visible, than those values that are inside are not posted to the page, Request.Form (don't have those values).

Yet, the Values in UpdateObjectArgs has all the values, even those that aren't visible to the user. Obviously this is not right.

Am I doing something wrong ?

Can you help me.

Thanks

RockfordLhotka replied on Friday, February 12, 2010

Actually it is "right".

CSLA doesn't get or create the values you are seeing. Those values are provided by data binding directly to the data source control, and the CslaDataSource control simply provides them to your event handler as-is, without alteration.

To understand how/why you get those values, you'll have to explore the ASP.NET data binding mechanism or ask Microsoft why they chose that implementation.

tiago.santos replied on Friday, February 12, 2010

Thanks, I was starting to suspect that :(

Can you suggest-me a solution ?

Maybe I can't hide the controls in the server side, and must hide it in the client side (with display:none). And somehow clear the values in the client side...

I realy cant understand why they simply see if the property that is being bind is visible or not.

 

EDIT:

Ok, a possible solution is to disable the viewstate of all the controls inside the hidden asp:Panel. This way when there is a new postback they loose the values Smile

I cannot simply disable the ViewState of the asp:Panel, because it would loose the state of the Visible in the next postbacks

tiago.santos replied on Friday, February 12, 2010

Here is the code

        private static void ChangeClearControl(Control panel, bool state)
        {
            panel.Visible = state;
            foreach (Control ctrl in panel.Controls)
            {
                ctrl.EnableViewState = state;
            }
        }

Copyright (c) Marimer LLC