I’m working on a page in an ASP.NET site where certain fields (table rows) are being hidden/displayed by some javascript/jquery code, based on selections made on the page by the user.
When the save button is clicked, in the server side code I want to only save the values of the controls in the rows that are visible, however following post back any style applied to the row (i.e. “display:none;”) by the javascript code is not available. I’ve tried doing the following to determine whether a row is visible:
If Not trRef.Attributes.CssStyle.Value.Contains("display:none;")
'row is visible
End If
But the CssStyle property is empty (as I gather the controls have been recreated from the viewstate). I thought I might be able to use Request.Form(control.UniqueID) (as per this post) but it seems this will only retrieve the value of a control, and nothing else?
How can I determine whether these rows are visible on post back?
Styles are not posted to the server, just form values.
You’ll need to generate a different mechanism. For instance a hidden field containing visible rows (or hidden ones) indexes separated by comman and you’d process this hidden field on the server.