Reputation: 516
The problem is simple, I have ids of the contols and i want to show/ hide them on some event.
Actually the problem is i have a direct event on dropdown change i have to hide some controls based on some cases
the code for the direct event is foreach (Control oControl in ProductConfiguration.Controls) { string strName = oControl.GetType().Name; oControl.Visible = false; DataRow[] drIRows = dtInfo.Select("ControlId='" + oControl.ID + "' AND ProductGroupId='" + CboProductGroup.Value + "'");
if (drIRows.Length > 0)
oControl.Visible = true;
}
but the visible property doesnt works with direct events, so my idea was to use javascript instead, can anyone help.
Upvotes: 1
Views: 1637
Reputation: 166
After rendering to the page, visibility cannot be modified since the "visible" property refers to whether or not the client even receives the object to be able to place it on the screen.
I suggest two things if you would like to dynamically change this.
If you use Hidden property, the client still receives the control to render (it simply doesn't display if set to true), and it can then be quite easily changed.
Upvotes: 1
Reputation: 1851
Please use the Hidden property instead.
The difference is explained here.
Also you can use the Show/Hide methods.
Upvotes: 0