Export (0) Print
Expand All

ImageField.DataAlternateTextField Property

Gets or sets the name of the field from the data source that contains the values to bind to the AlternateText property of each image in an ImageField object.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

[TypeConverterAttribute("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] 
public virtual string DataAlternateTextField { get; set; }
/** @property */
public String get_DataAlternateTextField ()

/** @property */
public void set_DataAlternateTextField (String value)

public function get DataAlternateTextField () : String

public function set DataAlternateTextField (value : String)

Not applicable.

Property Value

The name of the field to bind the AlternateText property of each image in an ImageField object.

Use the DataAlternateTextField property to specify the name of the filed from the data source that contains the values to bind to the AlternateText property of each image in an ImageField object. The enables you to have different alternate text for each image displayed. The alternate text is displayed when an image cannot be loaded or is unavailable. Browsers that support the ToolTips feature also display this text as a ToolTip.

NoteNote:

You can specify alternate text that applies to all images by setting the AlternateText property instead of this property. If both the AlternateText and DataAlternateTextField properties are set, the DataAlternateTextField field takes precedence.

The following example code demonstrates how to use the DataAlternateTextField property to specify the name of the field from the data source that contains the values to bind to the AlternateText property of each image in an ImageField object.


<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ImageField Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>ImageField Example</h3>
                       
      <asp:gridview id="EmployeesGrid"
        autogeneratecolumns="false"
        datasourceid="EmployeeSource"  
        runat="server">
      
        <columns>

          <asp:imagefield dataimageurlfield="PhotoPath"
            dataalternatetextfield="LastName"
            dataalternatetextformatstring="Photo: {0}" 
            nulldisplaytext="No image on file."
            headertext="Photo"  
            readonly="true"/>
          <asp:boundfield datafield="FirstName"
            headertext="First Name"/>
          <asp:boundfield datafield="LastName"
            headertext="Last Name"/>
        
        </columns>
        
      </asp:gridview>
          
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [PhotoPath] From [Employees]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </form>
  </body>
</html>


Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft