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

Public Shared ReadOnly Property Properties As SettingsPropertyCollection
public static SettingsPropertyCollection Properties { get; }
public: static property SettingsPropertyCollection^ Properties { SettingsPropertyCollection^ get (); }
アプリケーションのプロファイルの各プロパティに対する SettingsProperty オブジェクトから成る SettingsPropertyCollection。

例外の種類 | 条件 |
---|---|
System.Configuration.ConfigurationErrorsException | Web.config ファイルの profile セクションで指定されたプロパティの型を作成できませんでした。 または Web.config ファイルの profile セクションで、いずれかのプロパティの allowAnonymous 属性が true に設定され、anonymousIdentification 要素の enabled 属性が false に設定されています。 または Web.config ファイルの profile セクションで、いずれかのプロパティの serializeAs 属性が Binary に設定され、指定された type の IsSerializable プロパティが false を返します。 または プロファイル プロパティの provider 属性を使用して指定されたプロバイダの名前が、Providers コレクションに見つかりませんでした。 または プロファイル プロパティに対して指定された type が見つかりませんでした。 または プロファイルのプロパティが、profile セクションの inherits 属性で指定された基本クラスのプロパティ名と一致する名前で指定されています。 |

このプロパティを使用して、プロパティ名と型を含め、アプリケーションに設定されたプロファイル プロパティに関する情報を取得できます。また、各プロパティの ProfileProvider を参照することもできます。ProfileProvider は、データ ソースへのプロパティ値の格納、およびデータ ソースからのプロパティ値の取得を管理します。

次のコード例では、SettingsProperty オブジェクトの静的な Properties コレクションからの Name プロパティを GridView コントロールにバインドすることで、ユーザー プロファイル内のプロパティ名を一覧表示します。選択されたプロパティ値を、Item コレクションを使用して名前で取得します。ユーザー プロファイルのプロパティを指定する Web.config ファイルの例については、ProfileBase クラスの例を参照してください。
<%@ Page Language="VB" %> <%@ Import Namespace="System.Web.Profile" %> <script runat="server"> Public Sub Page_Load() If Not IsPostBack Then PropertiesListBox.DataSource = ProfileBase.Properties PropertiesListBox.DataBind() End If If Not PropertiesListBox.SelectedItem Is Nothing Then Dim propValue As Object = Profile(PropertiesListBox.SelectedItem.Text) Dim propType As Type = propValue.GetType() ' If the property is a value type, return ToString(). If propType Is GetType(String) Or propType.IsValueType Then ValueLabel.Visible = True ValueGridView.Visible = False ValueLabel.Text = propValue.ToString() Return End If ' Bind the property to a GridView. Try ValueGridView.DataSource = propValue ValueGridView.DataBind() ValueGridView.Visible = True ValueLabel.Visible = False Catch ' If the property is not bindable, return ToString(). ValueLabel.Visible = True ValueGridView.Visible = False ValueLabel.Text = propValue.ToString() End Try End If End Sub </script> <html> <head> <title>Home Page</title> </head> <body> <h3>View Profile properties:</h3> <form runat="server"> <table border=0 cellpadding=2 cellspacing=2> <tR> <td>Property</td> <td>Value</td> </tR> <tr> <td valign="top"> <asp:ListBox runat="server" id="PropertiesListBox" Rows="10" AutoPostBack="True" DataTextField="Name" /> </td> <td valign="top"> <asp:GridView runat="Server" id="ValueGridView" Visible="False" /> <asp:Label runat="Server" id="ValueLabel" Visible="False" /> </td> </tr> </table> </form> </body> </html>
<%@ Page Language="C#" %> <%@ Import Namespace="System.Web.Profile" %> <script runat="server"> public void Page_Load() { if (!IsPostBack) { PropertiesListBox.DataSource = ProfileBase.Properties; PropertiesListBox.DataBind(); } if (PropertiesListBox.SelectedItem != null) { object propValue = Profile[PropertiesListBox.SelectedItem.Text]; Type propType = propValue.GetType(); // If the property is a value type, return ToString(). if (propType == typeof(string) || propType.IsValueType) { ValueLabel.Visible = true; ValueGridView.Visible = false; ValueLabel.Text = propValue.ToString(); return; } // Bind the property to a GridView. try { ValueGridView.DataSource = propValue; ValueGridView.DataBind(); ValueGridView.Visible = true; ValueLabel.Visible = false; } catch { // If the property is not bindable, return ToString(). ValueLabel.Visible = true; ValueGridView.Visible = false; ValueLabel.Text = propValue.ToString(); } } } </script> <html> <head> <title>Home Page</title> </head> <body> <h3>View Profile properties:</h3> <form runat="server"> <table border=0 cellpadding=2 cellspacing=2> <tR> <td>Property</td> <td>Value</td> </tR> <tr> <td valign="top"> <asp:ListBox runat="server" id="PropertiesListBox" Rows="10" AutoPostBack="True" DataTextField="Name" /> </td> <td valign="top"> <asp:GridView runat="Server" id="ValueGridView" Visible="False" /> <asp:Label runat="Server" id="ValueLabel" Visible="False" /> </td> </tr> </table> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


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

- ProfileBase.Properties プロパティのページへのリンク