ProfileBase コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ProfileBase コンストラクタの意味・解説 

ProfileBase コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

ProfileBase クラスインスタンス作成します

名前空間: System.Web.Profile
アセンブリ: System.Web (system.web.dll 内)
構文構文

public ProfileBase ()
public:
ProfileBase ()
public ProfileBase ()
例外例外
例外種類条件

System.Configuration.Provider.ProviderException

Web.config ファイルprofile セクションenabled 属性false です。

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 属性指定され基本クラスプロパティ名と一致する名前で指定されています。

解説解説

ASP.NET では、ProfileBase クラス使用してユーザー プロファイルに対して使用されるクラス作成しますユーザー プロファイル有効にされたアプリケーション起動すると、ASP.NET によって、ProfileBase クラス継承する ProfileCommon 型の新しクラス作成されます。profile 構成セクション定義されているそれぞれのプロパティに対して厳密に指定されアクセサProfileCommon クラス追加されます。ProfileCommon クラス厳密に指定されアクセサは、ProfileBase 基本クラスの GetPropertyValue メソッドおよび SetPropertyValue メソッド呼び出してプロファイルプロパティ値の取得および設定それぞれ行いますProfileCommon クラスインスタンスは、ASP.NET アプリケーションProfile プロパティ値として設定されます。

メモメモ

Profile プロパティ格納されるクラス生成使用される基本クラスは、構成ファイルprofile セクションinherits 属性使用してオーバー ライドできます。この場合ProfileBase 基本クラスから継承するカスタム クラス指定します

このコンストラクタは、アプリケーション コード使用するためのものではありません。ユーザー プロファイルインスタンス作成するには、Create メソッド使用します

使用例使用例

string 型の ZipCode プロパティおよび StringCollection 型の RecentSearchList プロパティ含んだユーザー プロファイル指定する Web.config の例を次に示します生成される現在の HttpContext の Profile プロパティは、指定されている各プロパティに対して厳密に指定されアクセサ持ちます

<configuration>
   <connectionStrings>
       <add name="SqlServices" connectionString="Data Source=localhost;Integrated
 Security=SSPI;Initial Catalog=aspnetdb;" />
   </connectionStrings>

  <system.web>
   <anonymousIdentification enabled="true" />

   <profile defaultProvider="SqlProvider" >
     <providers>
       <add
         name="SqlProvider"
         connectionStringName="SqlServices"
         applicationName="ProfileBaseApplication"
         type="System.Web.Profile.SqlProfileProvider" />
     </providers>

     <properties>
       <add name="ZipCode" allowAnonymous="true" />
       <add name="RecentSearchList"
            type="System.Collections.Specialized.StringCollection"
            serializeAs="Xml"
            allowAnonymous="true" />
      </properties>
    </profile>
   </system.web>
</configuration>

次の ASP.NET ページでは、ユーザー プロファイルに対して指定されZipCode プロパティ読み込んだり、設定したりします

<%@ 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>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ProfileBase コンストラクタ」の関連用語

ProfileBase コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ProfileBase コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS