textbox in usercontrol looses value on postback

lamy

Regular
Joined
Dec 12, 2005
Messages
56
Location
under your bed
i have a usercontrol with a textbox control in it, im trying to make a "Text" property for it with both get and set, setting a value isnt a problem but somehow i cant manage to retain the value of the textbox as it postback

Visual Basic:
    <Bindable(True), Category("Appearance"), DefaultValue("")> _
    Public Property Text() As String
        Get
            Dim obj As Object = ViewState("Text")
            If Not (obj Is Nothing) Then
                Return CType(obj, String)
            Else
                Return String.Empty
            End If
        End Get
        Set(ByVal value As String)
            ViewState("Text") = value
        End Set
    End Property

doing this wont work if i typed-in anything and submit the form
Visual Basic:
   MyLabel.Text = MyControl.Text

anyone? :confused:
 
found the problem, my control in my web form has ReadOnly set to True (was hoping itll still pass the value since HTML form doesnt pass values only when its disabled)

any workaround for this?
 
Back
Top