Export (0) Print
Expand All

ImageField.DataImageUrlFormatString Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the string that specifies the format in which the URL for each image in an ImageField object is rendered.

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

public virtual string DataImageUrlFormatString { get; set; }
/** @property */
public String get_DataImageUrlFormatString ()

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

public function get DataImageUrlFormatString () : String

public function set DataImageUrlFormatString (value : String)

Property Value

A string that specifies the format in which the URL for each image in an ImageField object is rendered. The default is the empty string ("") , which indicates that no special formatting is applied to the URLs.

Use the DataImageUrlFormatString property to specify a custom format for the URLs of the images displayed in an ImageField object. This is useful when you need to generate a URL, such as when the ImageField object simply contains the file name. If the DataImageUrlFormatString property is not set, the URL values do not get any special formatting.

The format string can be any literal string and usually contains a placeholder for the field's value. For example, in the format string "Item Value: {0}", the "{0}" placeholder is replaced with the value of the fields specified by the DataImageUrlField property. The rest of the format string is displayed as literal text.

NoteNote

If the format string does not include a placeholder, the field's value from the data source is not included in the final display text.

The placeholder consists of two parts separated by a colon (":") and wrapped in braces ("{}"), in the form {A:Bxx}. The value before the colon (A in the general example) specifies the field value's index in a zero-based list of parameters.

NoteNote

This parameter is part of the formatting syntax. Because there is only one field value in each cell, this value can only be set to 0.

The colon and the values after the colon are optional. The character after the colon (B in the general example) specifies the format in which to display the value. The following table lists the common formats.

Format character

Description

C

Displays numeric values in currency format.

D

Displays numeric values in decimal format.

E

Displays numeric values in scientific (exponential) format.

F

Displays numeric values in fixed format.

G

Displays numeric values in general format.

N

Displays numeric values in number format.

X

Displays numeric values in hexadecimal format.

NoteNote

The format characters are not case sensitive, except for X, which displays the hexadecimal characters in the case specified.

The value after the format character (xx in the general example) specifies the number of significant digits or decimal places to display. For example, the format string "{0:F2}" displays a fixed-point number with 2 decimal places.

For more information on formatting, see Formatting Overview.

The following example code demonstrates how to use the DataImageUrlFormatString property to apply a custom format to the URL values for the images in an ImageField object.

ImageFieldImageUrlFormatString#1

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft