ImageField.AlternateText プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As ImageField Dim value As String value = instance.AlternateText instance.AlternateText = value
[LocalizableAttribute(true)] public: virtual property String^ AlternateText { String^ get (); void set (String^ value); }
/** @property */ public String get_AlternateText () /** @property */ public void set_AlternateText (String value)
ImageField オブジェクトに表示されるイメージの代替テキスト。既定値は空の文字列 ("") です。この値は、このプロパティが設定されていないことを示します。

ImageField オブジェクトに表示されるイメージの代替テキストを指定するには、AlternateText プロパティを使用します。イメージを読み込むことができなかったり、イメージにアクセスできなかった場合、代替テキストが表示されます。ツール ヒント機能をサポートしているブラウザの場合、このテキストはツール ヒントとしても表示されます。
![]() |
---|
このプロパティを設定した場合、ImageField オブジェクトに表示されるすべてのイメージで同じ代替テキストが共有されます。このプロパティを設定する代わりに、DataAlternateTextField プロパティを設定することにより、代替テキストをデータ ソース内のフィールドにバインドする方法もあります。これにより、表示されるイメージごとに異なる代替テキストが割り当てられます。AlternateText プロパティと DataAlternateTextField プロパティの両方が設定されている場合は、DataAlternateTextField プロパティが優先されます。 |
このプロパティの値は、設定時に、デザイナ ツールを使用してリソース ファイルに自動的に保存できます。詳細については、LocalizableAttribute、ASP.NET のグローバリゼーションおよびローカリゼーション の各トピックを参照してください。

AlternateText プロパティを使用して、ImageField オブジェクトに表示されるすべてのイメージに対し、代替テキストを指定する方法を次の例に示します。
<%@ Page language="VB" %> <html> <body> <form runat="server"> <h3>ImageField Example</h3> <asp:gridview id="EmployeesGrid" autogeneratecolumns="false" datasourceid="EmployeeSource" runat="server"> <columns> <asp:imagefield dataimageurlfield="PhotoPath" alternatetext="Employee Photo" 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>
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>ImageField Example</h3> <asp:gridview id="EmployeesGrid" autogeneratecolumns="false" datasourceid="EmployeeSource" runat="server"> <columns> <asp:imagefield dataimageurlfield="PhotoPath" alternatetext="Employee Photo" 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 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からImageField.AlternateText プロパティを検索する場合は、下記のリンクをクリックしてください。

- ImageField.AlternateText プロパティのページへのリンク