ProfileBase.SetPropertyValue メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim instance As ProfileBase Dim propertyName As String Dim propertyValue As Object instance.SetPropertyValue(propertyName, propertyValue)

例外の種類 | 条件 |
---|---|
System.Configuration.Provider.ProviderException | プロパティの allowAnonymous 属性が false である匿名プロファイルに対してプロパティ値を設定しようとしました。 |
System.Configuration.SettingsPropertyNotFoundException | 現在のプロファイルに対して定義されたプロパティはありません。 または 指定されたプロファイル プロパティ名が、現在のプロファイルに存在しません。 または |
System.Configuration.SettingsPropertyIsReadOnlyException | |
System.Configuration.SettingsPropertyWrongTypeException |

ASP.NET では、ProfileBase クラスを使用して、ユーザー プロファイルに対して使用されるクラスを作成します。ユーザー プロファイルが有効にされたアプリケーションを起動すると、ASP.NET によって、ProfileBase クラスを継承する ProfileCommon 型の新しいクラスが作成されます。profile 構成セクションに定義されているそれぞれのプロパティに対して、厳密に型指定されたアクセサが ProfileCommon クラスに追加されます。ProfileCommon クラスの厳密に型指定されたアクセサでは、SetPropertyValue メソッドを呼び出し、データ ソースに格納する ProfileProvider にプロパティ値を渡します。
SetPropertyValue メソッドを使用すると、アプリケーションのユーザー プロファイルのプロパティ値を名前によって代入できます。値は型指定されていません。型チェックはコンパイル時ではなく実行時に行われます。型を厳密に指定してプロファイルのプロパティ値にアクセスする場合は、各ページごとに使用できる Profile プロパティのメンバ (たとえば、Profile.CustomerAddress など) として、名前でプロパティにアクセスします。

ユーザー プロファイルに対して、指定された ZipCode プロパティを読み込んだり、設定したりする ASP.NET ページのコード例を次に示します。ユーザー プロファイルのプロパティを指定する Web.config ファイルの例については、ProfileBase クラスの例を参照してください。
<%@ Page Language="VB" %> <script runat="server"> Public Sub Page_PreRender() If Profile.ZipCode = Nothing Then PersonalizePanel.Visible = False GetZipCodePanel.Visible = True Else ZipCodeLabel.Text = Profile.ZipCode ' Get personalized information for zip code here. PersonalizePanel.Visible = True GetZipCodePanel.Visible = False End If End Sub Public Sub ChangeZipCode_OnClick(sender As Object, args As EventArgs) ZipCodeTextBox.Text = Profile.ZipCode Profile.ZipCode = Nothing PersonalizePanel.Visible = False GetZipCodePanel.Visible = True End Sub Public Sub EnterZipCode_OnClick(sender As Object, args As EventArgs) Profile.ZipCode = ZipCodeTextBox.Text End Sub </script> <html> <head> <title>Home Page</title> </head> <body> <form runat="server"> <table border=1 cellpadding=2 cellspacing=2> <tr> <td> <asp:Panel id="PersonalizePanel" runat="Server" Visible="False"> Information for Zip Code: <asp:Label id="ZipCodeLabel" Runat="Server" /><BR> <!-- Information for Zip Code here. --> <BR> <asp:LinkButton id="ChangeZipCodeButton" Runat="Server" Text="Change Your Zip Code" OnClick="ChangeZipCode_OnClick" /> </asp:Panel> <asp:Panel id="GetZipCodePanel" runat="Server" Visible="False"> You can personalize this page by entering your Zip Code: <asp:TextBox id="ZipCodeTextBox" Columns=5 MaxLength=5 runat="Server" /> <asp:LinkButton id="EnterZipCodeButton" Runat="Server" Text="Go" OnClick="EnterZipCode_OnClick" /> </asp:Panel> </td> </tr> </table> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> public void Page_PreRender() { if (Profile.ZipCode == null) { PersonalizePanel.Visible = false; GetZipCodePanel.Visible = true; } else { ZipCodeLabel.Text = Profile.ZipCode; // Get personalized information for zip code here. PersonalizePanel.Visible = true; GetZipCodePanel.Visible = false; } } public void ChangeZipCode_OnClick(object sender, EventArgs args) { ZipCodeTextBox.Text = Profile.ZipCode; Profile.ZipCode = null; PersonalizePanel.Visible = false; GetZipCodePanel.Visible = true; } public void EnterZipCode_OnClick(object sender, EventArgs args) { Profile.ZipCode = ZipCodeTextBox.Text; } </script> <html> <head> <title>Home Page</title> </head> <body> <form runat="server"> <table border=1 cellpadding=2 cellspacing=2> <tr> <td> <asp:Panel id="PersonalizePanel" runat="Server" Visible="False"> Information for Zip Code: <asp:Label id="ZipCodeLabel" Runat="Server" /><BR> <!-- Information for Zip Code here. --> <BR> <asp:LinkButton id="ChangeZipCodeButton" Runat="Server" Text="Change Your Zip Code" OnClick="ChangeZipCode_OnClick" /> </asp:Panel> <asp:Panel id="GetZipCodePanel" runat="Server" Visible="False"> You can personalize this page by entering your Zip Code: <asp:TextBox id="ZipCodeTextBox" Columns=5 MaxLength=5 runat="Server" /> <asp:LinkButton id="EnterZipCodeButton" Runat="Server" Text="Go" OnClick="EnterZipCode_OnClick" /> </asp:Panel> </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.SetPropertyValue メソッドを検索する場合は、下記のリンクをクリックしてください。

- ProfileBase.SetPropertyValue メソッドのページへのリンク