Does anyone know of an issue with setting the Visible property of a control to false causing the value to change?
In the code below, the line:
control.Visible = dr.ParmDisplay;
On some servers, if the control is not visible it is not saving the value that was just set above it. We have a test server that this code works just fine, but we have a customer that the value is not saving. If the control is visible, it saves/shows/stores the value just fine on any server.
Is there some security patch that changes how this works??? I've Google'd it, and I don't find anything related to the visible property having this affect.
Here's the full code for this procedure:
protected void LoadReport()
{
dsReport.ReportParametersDataTable dt = objLoadXml.GetReportParamet开发者_JAVA技巧ers(objReport.ReportName);
foreach (dsReport.ReportParametersRow dr in dt.Rows)
{
Control control = null;
IParm parameterControl = null;
if (dr.ParmType.ToUpper().StartsWith("DATERANGE"))
{
control = LoadControl("./UserControls/DateRange.ascx");
}
else if (dr.ParmType.ToUpper().StartsWith("DATE"))
{
control = LoadControl("./UserControls/Date.ascx");
}
else
{
control = LoadControl("./UserControls/Parameter.ascx");
}
control.EnableViewState = true;
parameterControl = (IParm)control;
parameterControl.ParmName = dr.ParmName;
parameterControl.ParmDescription = dr.ParmDescription;
parameterControl.ParmPickList = dr.ParmPickList.ToString();
if (dr["ParmDefaultValue"].ToString() != "")
parameterControl.ParmDefaultValue = dr.ParmDefaultValue;
control.Visible = dr.ParmDisplay;
PlaceHolder1.Controls.Add(control);
}
Thanks.
When you set a control to not visible, it does not get rendered to the browser. Therefore it will not be there on post back and the value won't make it back to the server.
If you need to persist the value w/out showing the control, store it directly in view state, or hidden input etc.
精彩评论