ASP.Net/Data Binding/Property Binding

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

Color Property binding

   <source lang="csharp">

<%@ 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>

Simple DataBinding Example

  The value for FontColor is 
     <font color="<%# FontColor %>"><%# FontColor %></font>.

</body> </html>

</source>
   
  


DataBind method example

   <source lang="csharp">

<%@ 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>

</source>