ImageField.ReadOnly Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene o imposta un valore che indica se i valori del campo specificato dalla DataImageUrlField proprietà possono essere modificati in modalità di modifica.
public:
virtual property bool ReadOnly { bool get(); void set(bool value); };
public virtual bool ReadOnly { get; set; }
member this.ReadOnly : bool with get, set
Public Overridable Property ReadOnly As Boolean
Valore della proprietà
true per indicare che i valori dei campi non possono essere modificati in modalità di modifica; in caso contrario, false. Il valore predefinito è false.
Esempio
Nell'esempio seguente viene illustrato come utilizzare la ReadOnly proprietà per indicare che i valori di campo che rappresentano gli URL delle immagini visualizzate in un ImageField oggetto non possono essere modificati in modalità di modifica.
<%@ 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 ReadOnly Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ImageField ReadOnly Example</h3>
<asp:gridview id="EmployeesGrid"
autogeneratecolumns="false"
datasourceid="EmployeeSource"
autogenerateeditbutton="true"
datakeynames="EmployeeID"
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]"
updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName Where [EmployeeId]=@EmployeeID"
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 ReadOnly Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ImageField ReadOnly Example</h3>
<asp:gridview id="EmployeesGrid"
autogeneratecolumns="false"
datasourceid="EmployeeSource"
autogenerateeditbutton="true"
datakeynames="EmployeeID"
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]"
updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName Where [EmployeeId]=@EmployeeID"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html>
Commenti
Per impostazione predefinita, i valori del campo specificato dalla DataImageUrlField proprietà possono essere modificati dall'utente quando un controllo associato a dati è in modalità di modifica. Per impedire all'utente di modificare i valori del campo, impostare questa proprietà su true.
Annotazioni
In un ImageField oggetto la DataImageUrlField proprietà contiene in genere il nome del campo che contiene gli URL delle immagini visualizzate nell'oggetto .