I have a very simple usercontrol, basically a textbox and a label, whose purpose is to toggle between one another. The control is bound during the page's Page_Load event
. On the UserControl's Page_Load
event, I call the Toggle() function, which shows or hides the appropriate control and sets its text based on a boolean Editable property and string Text property, respectively.
Here's my Toggle() method (remember Editable and Text are public properties):
Public Sub Toggle()
If Editable Then
txtText.Visible = True
lblText.Visible = False
txtText.Text = Text
txtText.CssClass = TextboxCSSClass
Else
txtText.Visible = False
lblText.Visible = True
lblText.Text = Text
lblText.CssClass = LabelCSSClass
End If
End Sub
My problem is also simple: when a button on the page calls the control's Toggle() method, the toggling works fine, but the text disappears! I've tried this with a normal unbound textbox next to it, and the textbox maintains its text value just fine. Is there something I'm missing?
Thanks for your help in advance.