ASP.Net/Data Binding/Property Binding

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Color Property binding

<%@ Page Language="VB" %>
<html>
<head>
   <title>Simple DataBinding Example</title>
   <script runat="server">
      Dim FontColor As String
      Sub Page_Load()
         FontColor = "Red"
         DataBind()
      End Sub
   </script>
</head>
<body>
   <h1>Simple DataBinding Example</h1>
   The value for FontColor is 
      <font color="<%# FontColor %>"><%# FontColor %></font>.
</body>
</html>



DataBind method example

<%@ Page Language="vb" %>
<html>
   <head>
      <title>DataBind method example</title>
      <script runat="server">
         Dim Color As System.Drawing.Color = System.Drawing.Color.Red
         Sub Page_Load()
            Message.Text = "ForeColor is: " & Color.Name
            DataBind()
         End Sub
      </script>
   </head>
<body>
   <asp:label id="Message" ForeColor="<%# Color %>" runat="server"/>
</body>
</html>