I solved the problem myself but thought I would share the solution with the rest of the community. To restate the problem: The custom webform class that I created needed to accept property value changes for client-side manipulated hidden values, as well as server-side events. The first version of the code worked fine for client-side and onLoad events, but not for PostBack events. Original Codepublic bool Locked { get { object savedState; object clientState; try { if (Request.Params["__SmartWebFormLocked"].ToString().Trim() != "") { clientState = Request.Params["__SmartWebFormLocked"].ToString().Trim(); this.ViewState["__SmartWebFormLocked"] = clientState.ToString(); } } catch{} savedState = this.ViewState["__SmartWebFormLocked"]; if (savedState != null) return bool.Parse(savedState.ToString()); else return false; } set{this.ViewState["__SmartWebFormLocked"] = value;} }
Modified Codeprivate string _Locked = ""; public bool Locked { get { if (_Locked != "") this.ViewState["__SmartWebFormLocked"] = bool.Parse(_Locked.ToString()); else { object savedState; object clientState; try { if (Request.Params["__SmartWebFormLocked"].ToString().Trim() != "") { clientState = Request.Params["__SmartWebFormLocked"].ToString().Trim(); this.ViewState["__SmartWebFormLocked"] = bool.Parse(clientState.ToString()); } } catch{} savedState = this.ViewState["__SmartWebFormLocked"]; if (savedState == null) this.ViewState["__SmartWebFormLocked"] = false; } return (bool)this.ViewState["__SmartWebFormLocked"]; } set { _Locked = value.ToString(); this.ViewState["__SmartWebFormLocked"] = value; } }
With the updated code, server-side property value changes take priority of the stored or client-side property value. If no server-side event 'sets' the private string associated with the public property, then the get event returns either the client-side value from postback events or the viewstate value assigned to the property. Hope this helps someone