Find Control in a page : Controls On Page « Page « ASP.Net






Find Control in a page

<%@ Page Language="vb" %>
<html>
   <head>
      <title>FindControl method example</title>
      <script runat="server">
         Sub Page_Load()
            Dim TheControl As Control = FindControl("Message")
            If Not TheControl Is Nothing Then
               Dim TheLabel As Label = CType(TheControl, Label)
               TheLabel.Text = "Found the label named Message!"
               TheLabel.BackColor = System.Drawing.Color.Blue
            End If
         End Sub
      </script>
   </head>
<body>
   <asp:label id="Message" runat="server"/>
</body>
</html>
           
       








Related examples in the same category

1.Page.HasControls property
2.Add asp control to page dynamically
3.Add control by index