PersistChildrenAttribute.Persist 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
디자인 타임에 중첩 내용을 중첩 컨트롤로 유지할지 여부를 결정하는 값을 가져옵니다.
public:
property bool Persist { bool get(); };
public bool Persist { get; }
member this.Persist : bool
Public ReadOnly Property Persist As Boolean
속성 값
중첩 내용을 중첩 컨트롤로 유지하려면 true
이고, 그렇지 않으면 false
입니다. 기본값은 true
입니다.
예제
다음 코드 예제에서는 속성의 Persist 값을 가져오는 방법을 보여 줍니다.
이 코드 예제는에 대해 제공 된 큰 예제의 일부는 PersistChildrenAttribute 클래스입니다.
<%@ Page Language="C#" %>
<%@ Register TagPrefix="AspSample" Assembly="Samples.AspNet.CS.Controls" Namespace="PersistChildrenSamples" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
// Create two new employees and add them to the custom control.
Employee e1 = new Employee("Employee 1", "Title 1", "Alias 1");
Employee e2 = new Employee("Employee 2", "Title 2", "Alias 2");
CollectionPropertyControl1.Employees.Add(e1);
CollectionPropertyControl1.Employees.Add(e2);
// Verify attribute values.
PersistChildrenAttribute p =
(PersistChildrenAttribute)Attribute.GetCustomAttribute(typeof(CollectionPropertyControl),
typeof(PersistChildrenAttribute));
StringBuilder sb = new StringBuilder();
sb.Append("The Persist property is " + p.Persist.ToString() + "<br />");
sb.Append("The UseCustomPersistence property is " + p.UsesCustomPersistence.ToString() + "<br />");
sb.Append("The IsDefault method returns " + p.IsDefaultAttribute().ToString());
Message.Text = sb.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>PersistChildrenAttribute</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Message"
runat="server"/>
<AspSample:CollectionPropertyControl id="CollectionPropertyControl1"
runat="server">
</AspSample:CollectionPropertyControl>
</div>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Register TagPrefix="AspSample" Assembly="Samples.AspNet.VB.Controls" Namespace="PersistChildrenSampleVB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
' Create two new employees and add them to the custom control.
Dim e1 As New Employee("Employee 1", "Title 1", "Alias 1")
Dim e2 As New Employee("Employee 2", "Title 2", "Alias 2")
CollectionPropertyControl1.Employees.Add(e1)
CollectionPropertyControl1.Employees.Add(e2)
' Verify attribute values.
Dim p As PersistChildrenAttribute = _
Attribute.GetCustomAttribute(GetType(CollectionPropertyControl), _
GetType(PersistChildrenAttribute))
Dim sb As New StringBuilder()
sb.Append("The Persist property is " & p.Persist.ToString() & "<br />")
sb.Append("The UseCustomPersistence property is " & p.UsesCustomPersistence.ToString() & "<br />")
sb.Append("The IsDefault method returns " & p.IsDefaultAttribute().ToString())
Message.Text = sb.ToString()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>PersistChildrenAttribute</title>
</head>
<body>
<form id="Form1" runat="server">
<div>
<asp:Label ID="Message"
runat="server"/>
<AspSample:CollectionPropertyControl id="CollectionPropertyControl1"
runat="server">
</AspSample:CollectionPropertyControl>
</div>
</form>
</body>
</html>