[RESOLVED] Seems unable to set value of hidden control
Note: Going to be posting a few silly questions (seems to be silly problems) so be warned, my webforms knowledge are pretty low.
I got a hidden control in a User Control, as follows:
Code:
<asp:HiddenField ID="workDateId" runat="server" Value="" />
The user control have a member:
Code:
public string WorkDateId { get; set; }
In the form load event for the user control I set the value of my hidden control to the value of my member:
Code:
workDateId.Value = WorkDateId;
I use the user control as follows:
Code:
var ctrl = (TestControl)LoadControl("TestControl.ascx");
ctrl.WorkDateId = "some nonsense";
var cell = new TableCell();
cell.Controls.Add(ctrl);
tblRow.Cells.Add(cell);
However, the value of the hidden control are never set.
So..what did I miss? :cool:
Re: Seems unable to set value of hidden control
Solved it. (guess I forgot the page lifecycle stuff)
Changed my auto property to set the control value as soon it's value changes.
Code:
private string _workDateId;
public string WorkDateId
{
get { return _workDateId; }
set
{
_workDateId = value;
workDateId.Value = _workDateId;
}
}
Okey Dokey now. (and posting next stupid one soon ;-) )
Re: Seems unable to set value of hidden control
Quote:
Originally Posted by
Krokonoster
guess I forgot the page lifecycle stuff
This is always something that comes back to bite you every so often :)