WebPartPersonalization 클래스

정의

하위 수준 개인 설정 작업을 구현합니다.

public ref class WebPartPersonalization
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.EmptyStringExpandableObjectConverter))]
public class WebPartPersonalization
[<System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.EmptyStringExpandableObjectConverter))>]
type WebPartPersonalization = class
Public Class WebPartPersonalization
상속
WebPartPersonalization
특성

예제

다음 코드 예제에서는 클래스가 사용되는 방법과 WebPartPersonalization 개인 설정 범위가 개인 설정된 속성의 결과에 미치는 영향을 보여 주는 예제를 제공합니다. 이 예제에는 5개의 파일이 있습니다.

  • 선언적으로 두 개의 웹 파트 영역을 만드는 .aspx 페이지로, 각각 컨트롤이 있습니다.

  • 사용자가 상태 정보를 수정하고 공유 범위를 입력할 수 있는 권한 부여 권한에 따라 텍스트 상자 배경색을 적용하는 개인 설정된 속성을 변경할 수 있도록 하는 사용자 컨트롤입니다 Color.ascx .

  • 현재 페이지 범위가 무엇인지, 현재 사용자가 공유 범위를 입력하거나 데이터를 수정해야 하는 권한을 나타내는 사용자 Persmode.ascx 컨트롤입니다. 하나는 범위를 변경하고 다른 하나는 현재 사용자 개인 설정 정보를 다시 설정하는 두 개의 단추도 제공합니다.

  • 사용자에게 권한을 부여하는 데 사용되는 로그인 컨트롤입니다.

  • 사용자에게 개인 설정 상태를 수정하고 공유 범위를 입력하도록 권한을 부여하는 예제를 제공하는 섹션이 있는 Web.config 파일입니다.

다음 코드는 웹 파트 영역과 두 개의 웹 파트 영역이 있는 WebPartManager aspx 페이지를 만들고 컨트롤과 Persmode.ascx 컨트롤을 Color.ascx 표시합니다. 페이지는 현재 사용자 정보를 가져오는 데 사용되는 로그인 페이지를 로드합니다. Microsoft Visual Studio 2005의 ASP.NET 웹 사이트 관리 도구를 사용하여 페이지에 액세스할 사용자를 만듭니다. 범위를 변경하고 상태 정보를 수정하기 위해 구성 파일에서 사용자에게 부여된 권한 부여의 예는 Web.config 파일을 참조하세요.

<%@ Page Language="C#" %>
<%@ Register TagPrefix="control"  TagName="colorcontrol" Src="~/color.ascx"%>
<%@Register TagPrefix="pmode" TagName="persmode" Src="~/persMode.ascx" %>


<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <!-- Create Web Part manager and zone for the color user control. -->
        <asp:WebPartManager ID="WebPartManager1" runat="server"></asp:WebPartManager>
            <asp:WebPartZone ID="WebPartZone1" runat="server" HeaderText="Color Change Zone">
                <ZoneTemplate>
                <!-- Note that the control is Shared since it is declared on the page. -->
                    <control:colorcontrol id="color1" title="Color Control" runat="server" />
                </ZoneTemplate>
            </asp:WebPartZone>
        
        <br />
            <!-- Create Web Part zone for the personalization mode user control. -->
            <asp:WebPartZone ID="WebPartZone2" runat="server" HeaderText="Scope Change Zone" Height="109px">
                <ZoneTemplate>
                    <pmode:persmode  ID="Persmode1" runat="server" title="Scope Tool"/>
                </ZoneTemplate>
            </asp:WebPartZone>
   
    </form>
</body>
</html>
<%@ Page Language="C#" %>
<%@ Register TagPrefix="control"  TagName="colorcontrol" Src="~/color.ascx"%>
<%@Register TagPrefix="pmode" TagName="persmode" Src="~/persMode.ascx" %>


<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <!-- Create Web Part manager and zone for the color user control. -->
        <asp:WebPartManager ID="WebPartManager1" runat="server"></asp:WebPartManager>
            <asp:WebPartZone ID="WebPartZone1" runat="server" HeaderText="Color Change Zone">
                <ZoneTemplate>
                <!-- Note that the control is Shared since it is declared on the page. -->
                    <control:colorcontrol id="color1" title="Color Control" runat="server" />
                </ZoneTemplate>
            </asp:WebPartZone>
        
        <br />
            <!-- Create Web Part zone for the personalization mode user control. -->
            <asp:WebPartZone ID="WebPartZone2" runat="server" HeaderText="Scope Change Zone" Height="109px">
                <ZoneTemplate>
                    <pmode:persmode  ID="Persmode1" runat="server" title="Scope Tool"/>
                </ZoneTemplate>
            </asp:WebPartZone>
   
    </form>
</body>
</html>

다음 예제 코드는 로그인 페이지를 만듭니다. 성공적으로 로그인하면 기본 aspx 페이지로 리디렉션됩니다.

중요

이 예제에는 사용자 입력을 허용하는 텍스트 상자가 있으므로 보안상 위험할 수 있습니다. 기본적으로 ASP.NET 웹 페이지는 사용자 입력 내용에 스크립트 또는 HTML 요소가 포함되어 있지 않은지 확인합니다. 자세한 내용은 Script Exploits Overview를 참조하세요.

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

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Login ID="Login1" runat="server" BorderWidth="1px" BorderColor="#E6E2D8" BorderPadding="4"
            BorderStyle="Solid" BackColor="#F7F6F3" ForeColor="#333333" Font-Names="Verdana"
            Font-Size="0.8em" DestinationPageUrl="~/Defaultcs.aspx">
            <InstructionTextStyle ForeColor="Black" Font-Italic="True" Font-Size="0.8em" />
            <LoginButtonStyle Font-Names="Verdana" Font-Size="0.8em" BorderStyle="Solid" BorderWidth="1px"
                BorderColor="#CCCCCC" BackColor="#FFFBFF" ForeColor="#284775" />
            <TextBoxStyle Font-Size="0.8em" />
            <LabelStyle Font-Size="0.8em" />
            <TitleTextStyle ForeColor="White" Font-Size="0.9em" Font-Bold="True" BackColor="#5D7B9D" />
            <HyperLinkStyle Font-Size="0.8em" />
            <CheckBoxStyle Font-Size="0.8em" />
            <FailureTextStyle ForeColor="#FF0000" Font-Size="0.8em" />
        </asp:Login>   
You can create new users with the ASP.NET Web Site Administration Tool in Microsoft Visual Studio 2005. 
See also the web.config file for user authorization examples.
    </div>
    </form>
</body>
</html>
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Login ID="Login1" runat="server" BorderWidth="1px" BorderColor="#E6E2D8" BorderPadding="4"
            BorderStyle="Solid" BackColor="#F7F6F3" ForeColor="#333333" Font-Names="Verdana"
            Font-Size="0.8em" DestinationPageUrl="~/Defaultvb.aspx">
            <InstructionTextStyle ForeColor="Black" Font-Italic="True" Font-Size="0.8em" />
            <LoginButtonStyle Font-Names="Verdana" Font-Size="0.8em" BorderStyle="Solid" BorderWidth="1px"
                BorderColor="#CCCCCC" BackColor="#FFFBFF" ForeColor="#284775" />
            <TextBoxStyle Font-Size="0.8em" />
            <LabelStyle Font-Size="0.8em" />
            <TitleTextStyle ForeColor="White" Font-Size="0.9em" Font-Bold="True" BackColor="#5D7B9D" />
            <HyperLinkStyle Font-Size="0.8em" />
            <CheckBoxStyle Font-Size="0.8em" />
            <FailureTextStyle ForeColor="#FF0000" Font-Size="0.8em" />
        </asp:Login>   
You can create new users with the ASP.NET Web Site Administration Tool in Microsoft Visual Studio 2005. 
See also the web.config file for user authorization examples.
    </div>
    </form>
</body>
</html>

다음 예제 코드는이 애플리케이션에 대 한 Web.config 파일의 일부입니다. 이 섹션에서는 사용자에 대한 권한 부여(이 경우 "user2")를 설정하여 공유 개인 설정 범위를 입력하고 개인 설정 상태 정보를 수정하는 방법을 보여줍니다. 또한 "admin" 역할의 사용자가 공유 개인 설정 범위를 입력하고 개인 설정 상태 정보를 수정할 수 있도록 허용하는 데 사용할 수 있는 역할의 예(이 경우 "admin")를 보여 있습니다.

<webParts>
    <personalization defaultProvider="AspNetSqlPersonalizationProvider">
        <authorization>
            <allow users="user2" verbs="enterSharedScope, modifyState"/>
            <allow roles="admin" verbs="enterSharedScope, modifyState"/>
        </authorization>
    </personalization>
</webParts>
<webParts>
    <personalization defaultProvider="AspNetSqlPersonalizationProvider">
        <authorization>
            <allow users="user2" verbs="enterSharedScope, modifyState"/>
            <allow roles="admin" verbs="enterSharedScope, modifyState"/>
        </authorization>
    </personalization>
</webParts>

다음 예제 코드는 현재 개인 설정 범위 및 사용자의 권한 부여 권한에 따라 두 텍스트 상자의 배경색을 사용자가 개인 설정된 속성을 변경할 수 있도록 하는 사용자 Color.ascx정의 컨트롤을 만듭니다.

중요

이 예제에는 사용자 입력을 허용하는 텍스트 상자가 있으므로 보안상 위험할 수 있습니다. 기본적으로 ASP.NET 웹 페이지는 사용자 입력 내용에 스크립트 또는 HTML 요소가 포함되어 있지 않은지 확인합니다. 자세한 내용은 Script Exploits Overview를 참조하세요.

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

<script runat="server">
    // User a field to reference the current WebPartManager.
    private WebPartManager _manager;
    
    //  Defines personalized property for User scope. In this case, the property is
    //   the background color of the text box.
    [Personalizable(PersonalizationScope.User)]
    public System.Drawing.Color UserColorChoice
    {
        get
        {
            return _coloruserTextBox.BackColor;
        }
        set
        {
            _coloruserTextBox.BackColor = value;
        }
    }

    // Defines personalized property for Shared scope. In this case, the property is
    //   the background color of the text box.
    [Personalizable(PersonalizationScope.Shared) ]
    public System.Drawing.Color SharedColorChoice
    {
        get
        {
            return _colorsharedTextBox.BackColor;
        }
        set
        {
            _colorsharedTextBox.BackColor = value;
        }
    }


    void Page_Init(object sender, EventArgs e)
    {
       _manager = WebPartManager.GetCurrentWebPartManager(Page);       
    }

    protected void Page_Load(object src, EventArgs e) 
    {
     // If Web Parts manager scope is User, hide the button that changes shared control.
       if (_manager.Personalization.Scope == PersonalizationScope.User)
       {
           _sharedchangeButton.Visible = false;
                  if (!_manager.Personalization.IsModifiable)
                      _userchangeButton.Enabled = false;
       }
       else
       {
           _sharedchangeButton.Visible = true; 
                  if (!_manager.Personalization.IsModifiable)
                    {
                      _sharedchangeButton.Enabled = false;
                      _userchangeButton.Enabled = false;
                    }
       } 
    }
    
    // Changes color of the User text box background when button clicked by authorized user.
    protected void _userButton_Click(object src, EventArgs e)
    {
        switch(_coloruserTextBox.BackColor.Name)
        {
            case "Red":
                _coloruserTextBox.BackColor = System.Drawing.Color.Yellow;
                break;
            case "Yellow":
                _coloruserTextBox.BackColor = System.Drawing.Color.Green;
                break;
            case "Green":
                _coloruserTextBox.BackColor = System.Drawing.Color.Red;
                break;
        }
    }
        
    // Changes color of the Shared text box background when button clicked by authorized user.
    protected void _sharedButton_Click(object src, EventArgs e)
    {
        switch (_colorsharedTextBox.BackColor.Name)
        {
            case "Red":
                _colorsharedTextBox.BackColor = System.Drawing.Color.Yellow;
                break;
            case "Yellow":
                _colorsharedTextBox.BackColor = System.Drawing.Color.Green;
                break;
            case "Green":
                _colorsharedTextBox.BackColor = System.Drawing.Color.Red;
                break;
        }        
    }   

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>WebParts Personalization Example</title>
</head>
<body>
<p>
    <asp:LoginName ID="LoginName1" runat="server" BorderWidth="500" BorderStyle="none" />
    <asp:LoginStatus ID="LoginStatus1" LogoutAction="RedirectToLoginPage" runat="server" />
</p>
    <asp:Label ID="ScopeLabel" Text="Scoped Properties:" runat="server" Width="289px"></asp:Label>
    <br />
    <table style="width: 226px">
        
        <tr>
            <td>
                <asp:TextBox ID="_coloruserTextBox" Font-Bold="True" Height="110px" 
                runat="server" Text="User Property" BackColor="red" Width="110px" /> 
            </td>
            <td>       
                <asp:TextBox ID="_colorsharedTextBox" runat="server" Height="110px" 
                Width="110px" Text="Shared Property" BackColor="red" Font-Bold="true" />
            </td>
       </tr>
        <tr>
            <td>
                <asp:Button Text="Change User Color" ID="_userchangeButton" 
                runat="server" OnClick="_userButton_Click" />
            </td>
            <td >
                <asp:Button Text="Change Shared Color" ID="_sharedchangeButton" 
                runat="server" OnClick="_sharedButton_Click" />
            </td>
        </tr>
    </table>
</body>
</html>
<%@ Control Language="VB" %>

<script runat="server">
     ' User a field to reference the current WebPartManager.
Private _manager As WebPartManager

'  Defines personalized property for User scope. In this case, the property is
'   the background color of the text box.

<Personalizable(PersonalizationScope.User)>  _
Public Property UserColorChoice() As System.Drawing.Color 
    Get
        Return _coloruserTextBox.BackColor
    End Get
    Set
        _coloruserTextBox.BackColor = value
    End Set
End Property

' Defines personalized property for Shared scope. In this case, the property is
'   the background color of the text box.

<Personalizable(PersonalizationScope.Shared)>  _
Public Property SharedColorChoice() As System.Drawing.Color 
    Get
        Return _colorsharedTextBox.BackColor
    End Get
    Set
        _colorsharedTextBox.BackColor = value
    End Set
End Property



Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) 
    _manager = WebPartManager.GetCurrentWebPartManager(Page)

End Sub 'Page_Init


Protected Sub Page_Load(ByVal src As Object, ByVal e As EventArgs) 
    ' If Web Parts manager scope is User, hide the button that changes shared control.
    If _manager.Personalization.Scope = PersonalizationScope.User Then
        _sharedchangeButton.Visible = False
        If Not _manager.Personalization.IsModifiable Then
            _userchangeButton.Enabled = False
        End If
    Else
        _sharedchangeButton.Visible = True
        If Not _manager.Personalization.IsModifiable Then
            _sharedchangeButton.Enabled = False
            _userchangeButton.Enabled = False
        End If
    End If

End Sub 'Page_Load
 
' Changes color of the User text box background when button clicked by authorized user.
Protected Sub _userButton_Click(ByVal src As Object, ByVal e As EventArgs) 
    Select Case _coloruserTextBox.BackColor.Name
        Case "Red"
            _coloruserTextBox.BackColor = System.Drawing.Color.Yellow
        Case "Yellow"
            _coloruserTextBox.BackColor = System.Drawing.Color.Green
        Case "Green"
            _coloruserTextBox.BackColor = System.Drawing.Color.Red
    End Select

End Sub '_userButton_Click


' Changes color of the Shared text box background when button clicked by authorized user.
Protected Sub _sharedButton_Click(ByVal src As Object, ByVal e As EventArgs) 
    Select Case _colorsharedTextBox.BackColor.Name
        Case "Red"
            _colorsharedTextBox.BackColor = System.Drawing.Color.Yellow
        Case "Yellow"
            _colorsharedTextBox.BackColor = System.Drawing.Color.Green
        Case "Green"
            _colorsharedTextBox.BackColor = System.Drawing.Color.Red
    End Select

End Sub '_sharedButton_Click

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>WebParts Personalization Example</title>
</head>
<body>
<p>
    <asp:LoginName ID="LoginName1" runat="server" BorderWidth="500" BorderStyle="none" />
    <asp:LoginStatus ID="LoginStatus1" LogoutAction="RedirectToLoginPage" runat="server" />
</p>
    <asp:Label ID="ScopeLabel" Text="Scoped Properties:" runat="server" Width="289px"></asp:Label>
    <br />
    <table style="width: 226px">
        
        <tr>
            <td>
                <asp:TextBox ID="_coloruserTextBox" Font-Bold="True" Height="110px" 
                runat="server" Text="User Property" BackColor="red" Width="110px" /> 
            </td>
            <td>       
                <asp:TextBox ID="_colorsharedTextBox" runat="server" Height="110px" 
                Width="110px" Text="Shared Property" BackColor="red" Font-Bold="true" />
            </td>
       </tr>
        <tr>
            <td>
                <asp:Button Text="Change User Color" ID="_userchangeButton" 
                runat="server" OnClick="_userButton_Click" />
            </td>
            <td >
                <asp:Button Text="Change Shared Color" ID="_sharedchangeButton" 
                runat="server" OnClick="_sharedButton_Click" />
            </td>
        </tr>
    </table>
</body>
</html>

다음 예제 코드는 현재 개인 설정 범위와 상태를 수정하고 공유 범위를 입력할 수 있는 사용자 권한을 보여 주는 사용자 컨트롤을 Persmode.ascx만듭니다. 또한 현재 개인 설정 상태를 다시 설정하기 위한 재설정 단추가 있습니다.

<%@ control language="C#" %>

<script runat="server">
  
 // Use a field to reference the current WebPartManager.
  private WebPartManager _manager;

    protected void Page_Load(object src, EventArgs e)
    {
        // Get the current Web Parts manager.
        _manager = WebPartManager.GetCurrentWebPartManager(Page);
        
        // All radio buttons are disabled; the button settings show what the current state is.
        EnterSharedRadioButton.Enabled = false;
        ModifyStateRadioButton.Enabled = false;

        // If Web Parts manager is in User scope, set scope button.
        if (_manager.Personalization.Scope == PersonalizationScope.User)
            UserScopeRadioButton.Checked = true;
        else
            SharedScopeRadioButton.Checked = true;

        // Based on current user rights to enter Shared scope, set buttons.
        if (_manager.Personalization.CanEnterSharedScope)
        {
            EnterSharedRadioButton.Checked = true;
            No_Shared_Scope_Label.Visible = false;
            Toggle_Scope_Button.Enabled = true;
        }
        else
        {
            EnterSharedRadioButton.Checked = false;
            No_Shared_Scope_Label.Visible = true;
            Toggle_Scope_Button.Enabled = false;
        }

        // Based on current user rights to modify personalization state, set buttons.
        if (_manager.Personalization.IsModifiable)
        {
            ModifyStateRadioButton.Checked = true;
            Reset_User_Button.Enabled = true;
        }
        else
        {
            ModifyStateRadioButton.Checked = false;
            Reset_User_Button.Enabled = false;
        }
    }
    // <snippet6>
  // Resets all of a user and shared personalization data for the page.
    protected void Reset_CurrentState_Button_Click(object src, EventArgs e)
    {
        // User must be authorized to modify state before a reset can occur.
        //When in user scope, all users by default can change their own data.
        if (_manager.Personalization.IsModifiable)
        {
            _manager.Personalization.ResetPersonalizationState();
        }
    }
  //  </snippet6>

    // <snippet7>
    // Allows authorized user to change personalization scope.
    protected void Toggle_Scope_Button_Click(object sender, EventArgs e)
    {
        if (_manager.Personalization.CanEnterSharedScope)
        {
            _manager.Personalization.ToggleScope();
        }
        
    }
 // </snippet7>
</script>
<div>
    &nbsp;<asp:Panel ID="Panel1" runat="server" 
    Borderwidth="1" 
    Width="208px" 
    BackColor="lightgray"
    Font-Names="Verdana, Arial, Sans Serif" Height="214px" >
    <asp:Label ID="Label1" runat="server" 
      Text="Page Scope" 
      Font-Bold="True"
      Font-Size="8pt"
      Width="120px" />&nbsp;<br />
    
    
      <asp:RadioButton ID="UserScopeRadioButton" runat="server" 
        Text="User" 
        AutoPostBack="true"
        GroupName="Scope"  
         Enabled="false" />
      <asp:RadioButton ID="SharedScopeRadioButton" runat="server" 
        Text="Shared" 
        AutoPostBack="true"
        GroupName="Scope" 
        Enabled="false" />
        <br />
        <asp:Label BorderStyle="None" Font-Bold="True" Font-Names="Courier New" ID="No_Shared_Scope_Label" Font-Size="Smaller" ForeColor="red"
           runat="server" Visible="false" Width="179px">User cannot enter Shared scope</asp:Label>
        <br />
        <asp:Label ID="Label2" runat="server" 
      Text="Current User Can:" 
      Font-Bold="True"
      Font-Size="8pt"
      Width="165px" />
      <br />
        <asp:RadioButton ID="ModifyStateRadioButton" runat="server" 
        Text="Modify State" Width="138px" />
        <br />
        <asp:RadioButton ID="EnterSharedRadioButton" runat="server" 
        Text="Enter Shared Scope" 
        AutoPostBack="true"  />&nbsp;<br />
        <br />
        <asp:Button ID="Toggle_Scope_Button" OnClick="Toggle_Scope_Button_Click" runat="server"
            Text="Change Scope" Width="186px" /><br />
        <br />
        <asp:Button ID="Reset_User_Button" OnClick="Reset_CurrentState_Button_Click" runat="server"
            Text="Reset Current Personalization" Width="185px" /></asp:Panel>
    &nbsp; &nbsp;
</div>
<%@ control language="VB" %>

<script runat="server">
  
  ' Use a field to reference the current WebPartManager.
Private _manager As WebPartManager


Protected Sub Page_Load(ByVal src As Object, ByVal e As EventArgs) 
    ' Get the current Web Parts manager.
    _manager = WebPartManager.GetCurrentWebPartManager(Page)
    
    ' All radio buttons are disabled; the button settings show what the current state is.
    EnterSharedRadioButton.Enabled = False
    ModifyStateRadioButton.Enabled = False
    
    ' If Web Parts manager is in User scope, set scope button.
    If _manager.Personalization.Scope = PersonalizationScope.User Then
        UserScopeRadioButton.Checked = True
    Else
        SharedScopeRadioButton.Checked = True
    End If 
    ' Based on current user rights to enter Shared scope, set buttons.
    If _manager.Personalization.CanEnterSharedScope Then
        EnterSharedRadioButton.Checked = True
        No_Shared_Scope_Label.Visible = False
        Toggle_Scope_Button.Enabled = True
    Else
        EnterSharedRadioButton.Checked = False
        No_Shared_Scope_Label.Visible = True
        Toggle_Scope_Button.Enabled = False
    End If
    
    ' Based on current user rights to modify personalization state, set buttons.
    If _manager.Personalization.IsModifiable Then
        ModifyStateRadioButton.Checked = True
        Reset_User_Button.Enabled = True
    Else
        ModifyStateRadioButton.Checked = False
        Reset_User_Button.Enabled = False
    End If

End Sub 'Page_Load

' <snippet6>
' Resets all of a user and shared personalization data for the page.
Protected Sub Reset_CurrentState_Button_Click(ByVal src As Object, ByVal e As EventArgs) 
    ' User must be authorized to modify state before a reset can occur.
    'When in user scope, all users by default can change their own data.
    If _manager.Personalization.IsModifiable Then
        _manager.Personalization.ResetPersonalizationState()
    End If

End Sub 'Reset_CurrentState_Button_Click

'  </snippet6>
' <snippet7>
' Allows authorized user to change personalization scope.
Protected Sub Toggle_Scope_Button_Click(ByVal sender As Object, ByVal e As EventArgs) 
    If _manager.Personalization.CanEnterSharedScope Then
        _manager.Personalization.ToggleScope()
    End If

End Sub 'Toggle_Scope_Button_Click 
' </snippet7>
</script>
<div>
    &nbsp;<asp:Panel ID="Panel1" runat="server" 
    Borderwidth="1" 
    Width="208px" 
    BackColor="lightgray"
    Font-Names="Verdana, Arial, Sans Serif" Height="214px" >
    <asp:Label ID="Label1" runat="server" 
      Text="Page Scope" 
      Font-Bold="True"
      Font-Size="8pt"
      Width="120px" />&nbsp;<br />
    
    
      <asp:RadioButton ID="UserScopeRadioButton" runat="server" 
        Text="User" 
        AutoPostBack="true"
        GroupName="Scope"  
         Enabled="false" />
      <asp:RadioButton ID="SharedScopeRadioButton" runat="server" 
        Text="Shared" 
        AutoPostBack="true"
        GroupName="Scope" 
        Enabled="false" />
        <br />
        <asp:Label BorderStyle="None" Font-Bold="True" Font-Names="Courier New" ID="No_Shared_Scope_Label" Font-Size="Smaller" ForeColor="red"
           runat="server" Visible="false" Width="179px">User cannot enter Shared scope</asp:Label>
        <br />
        <asp:Label ID="Label2" runat="server" 
      Text="Current User Can:" 
      Font-Bold="True"
      Font-Size="8pt"
      Width="165px" />
      <br />
        <asp:RadioButton ID="ModifyStateRadioButton" runat="server" 
        Text="Modify State" Width="138px" />
        <br />
        <asp:RadioButton ID="EnterSharedRadioButton" runat="server" 
        Text="Enter Shared Scope" 
        AutoPostBack="true"  />&nbsp;<br />
        <br />
        <asp:Button ID="Toggle_Scope_Button" OnClick="Toggle_Scope_Button_Click" runat="server"
            Text="Change Scope" Width="186px" /><br />
        <br />
        <asp:Button ID="Reset_User_Button" OnClick="Reset_CurrentState_Button_Click" runat="server"
            Text="Reset Current Personalization" Width="185px" /></asp:Panel>
    &nbsp; &nbsp;
</div>

설명

이 클래스는 하위 수준 개인 설정 작업을 수행하는 데 필요한 논리를 구현합니다. 클래스는 WebPartManager 개인 설정 WebPartPersonalization 의 개략적인 수명 주기를 관리하지만 특정 개인 설정 작업을 수행하는 데 필요한 물리적 단계를 실제로 구현하는 것은 클래스입니다. 클래스는 WebPartPersonalization 개인 설정 정보에 대한 기본 데이터 저장소와 통신하기 위한 구현 PersonalizationProvider 에 의존합니다.

기본 구현 WebPartManager을 사용하는 경우 속성을 참조하여 사용할 수 있는 클래스의 WebPartPersonalization 인스턴스를 Personalization 만듭니다. 예를 들어 속성WebPartManager.Personalization.InitialScope에 액세스하려면 .InitialScope

상속자 참고

클래스는 WebPartPersonalization 컨트롤 및 나머지 개인 설정 인프라와 긴밀하게 WebPartManager 작동합니다. 개인 설정의 기본 구현은 개인 설정 요구 사항을 충족해야 하는 매우 강력한 하위 시스템입니다. 대부분의 경우 개인 설정을 사용자 지정하려는 경우 상속되는 클래스를 만들어 개인 설정 공급자로 사용할 데이터 공급자를 만들 수 있습니다 PersonalizationProvider.

개인 설정 하위 시스템을 클래스 및 WebPartManager 클래스에서 제공하는 WebPartPersonalization 것과 크게 다르게 만들려면 사용자 지정 논리에서 WebPartPersonalization 파생하여 사용자 지정 WebPartPersonalization 구현을 만들고 고유한 사용자 지정 논리를 추가해야 합니다. 그런 다음, WebPartManager파생하여 사용자 지정 WebPartManager 구현을 만들고, 고유한 사용자 지정 논리를 추가하고, 메서드를 재정의 CreatePersonalization() 하여 사용자 지정 WebPartPersonalization 구현을 반환합니다. 컨트롤은 WebPartManager 인스턴스를 통해 WebPartPersonalization 개인 설정 인프라에 대한 요청을 수행하므로 컨트롤이 WebPartManager 구현에 대한 참조 PersonalizationProvider 와 직접 상호 작용하거나 보유하지 않습니다.

생성자

WebPartPersonalization(WebPartManager)

WebPartPersonalization 클래스의 새 인스턴스를 초기화합니다.

필드

EnterSharedScopeUserCapability

WebPartUserCapability 범위에 진입하기 위한 사용자 권한의 Shared 인스턴스를 나타냅니다.

ModifyStateUserCapability

개인 설정 상태를 수정하기 위한 사용자 권한의 WebPartUserCapability 인스턴스를 나타냅니다.

속성

CanEnterSharedScope

Shared 범위에 진입하는 데 필요한 권한이 사용자에게 부여되어 있는지 나타내는 값을 반환합니다.

Enabled

연결된 WebPartManager 컨트롤에 대해 개인 설정을 활성화하도록 요청했는지 나타내는 값을 반환합니다.

HasPersonalizationState

현재 페이지와 개인 설정 범위에 연결된 개인 설정 데이터가 있는지 나타내는 값을 반환합니다.

InitialScope

기본 개인 설정 범위를 가져오거나 설정합니다.

IsEnabled

개인 설정을 활성화하고 WebPartPersonalization 클래스의 이 인스턴스에 대해 개인 설정 데이터를 성공적으로 로드했는지 나타내는 값을 가져옵니다.

IsInitialized

개인 설정을 활성화하고 WebPartPersonalization 클래스의 이 인스턴스에 대해 개인 설정 데이터를 성공적으로 로드했는지 나타내는 값을 가져옵니다.

IsModifiable

상태 정보를 수정하는 데 필요한 권한이 현재 사용자에게 부여되어 있는지 나타내는 값을 가져옵니다.

ProviderName

개인 설정의 공급자 이름을 가져오거나 설정합니다.

Scope

부모 WebPartManager 컨트롤에 대한 현재 개인 설정 범위를 가져옵니다.

ShouldResetPersonalizationState

내부 데이터 저장소에서 개인 설정 데이터를 삭제하도록 요청한 경우와 같이 현재 페이지의 개인 설정 데이터가 다시 설정되었는지 나타내는 값을 가져오거나 설정합니다.

UserCapabilities

현재 사용자에게 부여되는 WebPartUserCapability의 사용자 기능을 가져오거나 설정합니다.

WebPartManager

WebPartManager 인스턴스에 연결된 현재 부모 WebPartPersonalization 컨트롤의 인스턴스를 가져옵니다.

메서드

ApplyPersonalizationState()

개인 설정 데이터를 부모 WebPartManager 컨트롤에 적용합니다.

ApplyPersonalizationState(WebPart)

지정된 WebPart 컨트롤에 개인 설정 데이터를 적용합니다. 이 작업은 부모 WebPartManager 컨트롤의 요청이 있을 때 수행됩니다.

ChangeScope(PersonalizationScope)

현재 페이지의 PersonalizationScope 인스턴스를 지정된 범위로 변경합니다.

CopyPersonalizationState(WebPart, WebPart)

웹 파트 컨트롤 하나에서 개인 설정 상태를 추출하고 이 상태를 두 번째 웹 파트 컨트롤에 적용합니다.

EnsureEnabled(Boolean)

WebPartPersonalization 인스턴스의 초기화가 완료되었는지 또는 개인 설정 상태를 수정하는 데 필요한 권한이 현재 사용자에게 있는지 확인합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
ExtractPersonalizationState()

부모 WebPartManager 컨트롤에서 개인 설정 데이터를 추출합니다.

ExtractPersonalizationState(WebPart)

웹 파트 컨트롤에서 개인 설정 데이터를 추출합니다. 이 작업은 부모 WebPartManager 컨트롤의 요청이 있을 때 수행됩니다.

GetAuthorizationFilter(String)

지정한 웹 파트 컨트롤에 연결된 권한 부여 필터가 있는 경우 이 필터를 검색합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
Load()

개인 설정을 초기화합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ResetPersonalizationState()

내부 데이터 저장소에서 현재 페이지, 범위 및 사용자에 대한 개인 설정 데이터를 다시 설정합니다.

Save()

현재 페이지, 범위 및 사용자에 대한 개인 설정 데이터를 내부 데이터 저장소에 저장합니다.

SetDirty()

부모 WebPartManager 컨트롤에 변경된 개인 설정 데이터가 있는 것으로 표시합니다.

SetDirty(WebPart)

지정된 웹 파트 컨트롤에 변경된 개인 설정 데이터가 있는 것으로 표시합니다.

ToggleScope()

현재 페이지의 개인 설정 범위를 User에서 Shared로 또는 Shared에서 User로 전환합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보