PersonalizableAttribute クラスとは? わかりやすく解説

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

PersonalizableAttribute クラス

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

パーソナル化属性表します。このクラス継承できません。

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

<AttributeUsageAttribute(AttributeTargets.Property)> _
Public NotInheritable Class
 PersonalizableAttribute
    Inherits Attribute
Dim instance As PersonalizableAttribute
[AttributeUsageAttribute(AttributeTargets.Property)] 
public sealed class PersonalizableAttribute
 : Attribute
[AttributeUsageAttribute(AttributeTargets::Property)] 
public ref class PersonalizableAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property) */ 
public final class PersonalizableAttribute
 extends Attribute
AttributeUsageAttribute(AttributeTargets.Property) 
public final class PersonalizableAttribute
 extends Attribute
解説解説

パーソナル化属性 Personalizable は、パーソナル化情報保持する必要があるパブリック コントロール プロパティ適用されます。コントロールWeb パーツ ページ上の Web パーツ ゾーンにある場合、これらの値を保持したり、基になるデータ ストアから取得したりするコードは、ASP.NET によって自動生成されます

プロパティパーソナル化可能とマークするには、次の要件満たしている必要があります

プロパティパーソナル化データ読み込みおよび保存を行うコード自動的に生成されます。パーソナル化サポートするプロパティは、プロパティにこの属性存在するかどうか、およびプロパティ上記制約準拠しているかどうか基づいて決まります

読み取り専用プロパティおよび書き込み専用プロパティパーソナル化は、サポートされていません。読み取り専用プロパティまたは書き込み専用プロパティにこの属性適用すると、HttpException がスローさます。パラメータ付きプロパティ場合も、HttpException 例外スローさます。

この属性持たない個々プロパティは、IPersonalizable インターフェイス通じて特別な処理を行わなければパーソナル化から除外されます。

属性使用方法については、「Web パーツパーソナル化概要」を参照してください

使用例使用例

コードPersonalizableAttribute クラス使用する方法を示すコード例次に示します。この例は、ColorSelector.ascx という Web パーツ ユーザー コントロール参照する .aspx ページ構成されています。.aspx ファイルコード例次に示します

<%@ Page Language="C#"  %>
<%@ Register TagPrefix="uc1" TagName="colorcontrol" Src="ColorSelector.ascx"
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html  >
<head runat="server">
    <title>Untitled Page</title>
</head>
       
<body>
    <form id="form1" runat="server">
      <div>
        &nbsp;<asp:LoginName ID="LoginName1" runat="server"
 />
        &nbsp;
        <asp:LoginStatus ID="LoginStatus1" runat="server"
 LogoutAction="RedirectToLoginPage" />
        &nbsp;&nbsp;&nbsp;&nbsp;<br />
        <br />
        &nbsp;<asp:WebPartManager ID="WebPartManager1" runat="server">
        </asp:WebPartManager>
    
    </div>
        <asp:WebPartZone ID="WebPartZone1" runat="server"
  Height=200 Width=200>
        <ZoneTemplate>
        <uc1:colorcontrol id=colorcontrol runat=server />
        </ZoneTemplate>
        </asp:WebPartZone>        
    </form>
</body>
</html>

次のコードは、ColorSelector.ascx コントロールの例です。

<%@ Control Language="C#" %>

<script runat=server>
private System.Drawing.Color userchoice;

[Personalizable]
public System.Drawing.Color UserColorChoice
{
   get
   {
     return userchoice;
   }
   set
   {
     userchoice = value;
   }
}

protected void OnRed(object src, EventArgs
 e)
{
  _color.BackColor = System.Drawing.Color.Red;
  UserColorChoice = System.Drawing.Color.Red;
}

protected void OnGreen(object src, EventArgs
 e)
{
  _color.BackColor = System.Drawing.Color.Green;
  UserColorChoice = System.Drawing.Color.Green;
}

protected void OnBlue(object src, EventArgs
 e)
{
  _color.BackColor = System.Drawing.Color.Blue;
  UserColorChoice = System.Drawing.Color.Blue;
}

protected void Page_Init(object src, EventArgs
 e)
{
  _redButton.Click   += new EventHandler(OnRed);  
  _greenButton.Click += new EventHandler(OnGreen);  
  _blueButton.Click  += new EventHandler(OnBlue);  
}

protected void Page_Load(object src, EventArgs
 e)
{
  if (!IsPostBack)
  {
          _color.BackColor = UserColorChoice;
  }
}

</script>
<body>
    
    <asp:TextBox ID=_color runat=server Height=100 Width=100 />
    <p>
    <asp:button runat=server  id=_redButton text="Red"  /> 
    &nbsp;&nbsp;
    <asp:button runat=server  id=_greenButton text="Green" />
    &nbsp;&nbsp;
    <asp:button runat=server id=_blueButton text="Blue" />
    
</body>
継承階層継承階層
System.Object
   System.Attribute
    System.Web.UI.WebControls.WebParts.PersonalizableAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
PersonalizableAttribute メンバ
System.Web.UI.WebControls.WebParts 名前空間



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

辞書ショートカット

すべての辞書の索引

「PersonalizableAttribute クラス」の関連用語

PersonalizableAttribute クラスのお隣キーワード
検索ランキング

   

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



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

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

©2024 GRAS Group, Inc.RSS