Home » .NET 4.0 » Form control state in code behind

Form control state in code behind

On page load event we define button css properties

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
                        Handles Me.Load
  
'define control css
   ValidatUser.Attributes.Add("class", "btnSubmit")
   vUsername.Attributes.Add("class", "txtBox")

'on post back page we change the state of control        
   If Page.IsPostBack Then
     'hide validate button
     ValidateUser.Visible = False
     'disable textbox
      vUsername.Enabled = False
   End If
End Sub

I hope you get the idea.