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

Dim instance As ImageField Dim value As String value = instance.NullImageUrl instance.NullImageUrl = value
/** @property */ public String get_NullImageUrl () /** @property */ public void set_NullImageUrl (String value)
フィールドの値が null 参照 (Visual Basic では Nothing) のときに表示される代替イメージの URL。既定値は空の文字列 ("") です。この値は、このプロパティが設定されていないことを示します。

DataImageUrlField プロパティによって指定されたフィールドの値が null 参照 (Visual Basic では Nothing) の場合、ImageField オブジェクトにイメージは表示されません。表示される代替イメージの URL を指定するには、NullImageUrl プロパティを使用します。通常、代替イメージには、本来表示されるはずのイメージが利用できないか、見つからなかったことを示すイメージを指定します。
![]() |
---|
このプロパティの代わりに NullDisplayText プロパティを設定することにより、フィールド値が null 参照 (Visual Basic では Nothing) のときに簡単なテキストを表示することもできます。NullImageUrl プロパティと NullDisplayText プロパティの両方が設定されている場合は、NullImageUrl プロパティが優先されます。 |

DataImageUrlField プロパティで指定されたフィールドの値が null 参照 (Visual Basic では Nothing) のときに表示される代替イメージの URL を、NullImageUrl プロパティを使って指定する方法を次の例に示します。
<%@ 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" nullimageurl="~\Images\NoPhoto.jpg" 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" nullimageurl="~\Images\NoPhoto.jpg" 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.NullImageUrl プロパティを検索する場合は、下記のリンクをクリックしてください。

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