ImageField.NullImageUrl プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ImageField プロパティで指定されたフィールドの値が null
のときに、DataImageUrlField オブジェクトに表示される代替イメージの URL を取得または設定します。
public:
virtual property System::String ^ NullImageUrl { System::String ^ get(); void set(System::String ^ value); };
public virtual string NullImageUrl { get; set; }
member this.NullImageUrl : string with get, set
Public Overridable Property NullImageUrl As String
プロパティ値
フィールドの値が null
のときに表示される代替イメージの URL。 既定値は空の文字列 ("") です。このプロパティが設定されていないことを示します。
例
次の例では、 プロパティをNullImageUrl使用して、 プロパティで指定されたフィールドの値が の場合に表示する代替イメージの URL を指定する方法をDataImageUrlFieldnull
示します。
<%@ 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"
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="VB" %>
<!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"
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>
注釈
プロパティで DataImageUrlField 指定されたフィールドの値が の場合、 null
イメージを ImageField オブジェクトに表示できません。 プロパティを NullImageUrl 使用して、表示する代替イメージの URL を指定します。 代替イメージは、通常、通常のイメージが使用できないか、見つからないことを示すイメージです。
注意
別の方法として、フィールド値が の場合は null
、このプロパティの代わりに プロパティを設定することで、単にテキストを NullDisplayText 表示できます。 NullImageUrlプロパティと NullDisplayText プロパティの両方が設定されている場合は、 NullImageUrl プロパティが優先されます。
適用対象
こちらもご覧ください
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示