View.Deactivate 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 활성 View 컨트롤이 비활성화될 때 발생합니다.
public:
event EventHandler ^ Deactivate;
public event EventHandler Deactivate;
member this.Deactivate : EventHandler
Public Custom Event Deactivate As EventHandler
이벤트 유형
예제
다음 코드 예제에는 지정 하 고 이벤트 처리기를 코딩 하는 방법을 보여 줍니다.는 Deactivate 의 이벤트는 View 제어 합니다. 활성 뷰가 변경, 사용자 지정 하는 메시지가 표시 됩니다는 View 발생 하는 컨트롤을 합니다 Activate 이벤트 및 View 발생 하는 컨트롤을 Deactivate 이벤트입니다.
<%@ Page Language="C#" %>
<!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>
<title>View.Activate Event Example</title>
<script runat="server">
protected void Index_Changed(object sender, EventArgs e)
{
// Set the active view to
// the view selected by the user.
String str = ViewListBox.SelectedItem.Text;
switch (str)
{
case "DefaultView":
MultiView1.SetActiveView(DefaultView);
break;
case "NewsView":
MultiView1.SetActiveView(NewsView);
break;
case "ShoppingView":
MultiView1.SetActiveView(ShoppingView);
break;
}
}
// The handler for the DefaultView's Activate event.
protected void DefaultView_Activate(object sender, EventArgs e)
{
// Notify the user that the event was raised.
ActivateLabel.Text = "The Activate event was raised for the DefaultView.";
}
// The handler for the DefaultView's Deactivate event.
protected void DefaultView_Deactivate(object sender, EventArgs e)
{
// Notify the user that the event was raised.
DeactivateLabel.Text = "The Deactivate event was raised for the DefaultView.";
}
// The handler for the ShoppingView's Activate event.
protected void ShoppingView_Activate(object sender, EventArgs e)
{
// Notify the user that the event was raised.
ActivateLabel.Text = "The Activate event was raised for the ShoppingView.";
}
// The handler for the ShoppingView's Deactivate event.
protected void ShoppingView_Deactivate(object sender, EventArgs e)
{
// Notify the user that the event was raised.
DeactivateLabel.Text = "The Deactivate event was raised for the ShoppingView.";
}
// The handler for the NewsView's Activate event.
protected void NewsView_Activate(object sender, EventArgs e)
{
// Notify the user that the event was raised.
ActivateLabel.Text = "The Activate event was raised for the NewsView.";
}
// The handler for the NewsView's Deactivate event.
protected void NewsView_Deactivate(object sender, EventArgs e)
{
// Notify the user that the event was raised.
DeactivateLabel.Text = "The Deactivate event was raised for the NewsView.";
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
MultiView1.SetActiveView(DefaultView);
}
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<h3>
View Activate and Deactivate Events Example</h3>
<h4>
Select a view to display in a MultiView control:</h4>
<asp:ListBox ID="ViewListBox" Rows="1" SelectionMode="Single" AutoPostBack="True"
OnSelectedIndexChanged="Index_Changed" runat="Server">
<asp:ListItem Value="0">DefaultView</asp:ListItem>
<asp:ListItem Value="1">NewsView</asp:ListItem>
<asp:ListItem Value="2">ShoppingView</asp:ListItem>
</asp:ListBox><br />
<br />
<hr />
<asp:MultiView ID="MultiView1" runat="Server">
<asp:View ID="DefaultView" OnActivate="DefaultView_Activate" OnDeactivate="DefaultView_Deactivate"
runat="Server">
<asp:Panel ID="DefaultPanel1" Width="250px" BackColor="#C0C0FF" BorderColor="#404040"
BorderStyle="Double" runat="Server">
<asp:Label ID="DefaultLabel1" Font-Bold="true" Font-Size="20" Text="The Default View"
runat="Server" AssociatedControlID="DefaultView">
</asp:Label>
</asp:Panel>
</asp:View>
<asp:View ID="NewsView" OnActivate="NewsView_Activate" OnDeactivate="NewsView_Deactivate"
runat="Server">
<asp:Panel ID="NewsPanel1" Width="250px" BackColor="#C0FFC0" BorderColor="#404040"
BorderStyle="Double" runat="Server">
<asp:Label ID="NewsLabel1" Font-Bold="true" Font-Size="20" Text="The News View" runat="Server"
AssociatedControlID="NewsView">
</asp:Label>
</asp:Panel>
</asp:View>
<asp:View ID="ShoppingView" OnActivate="ShoppingView_Activate" OnDeactivate="ShoppingView_Deactivate"
runat="Server">
<asp:Panel ID="ShoppingPanel1" Width="250px" BackColor="#FFFFC0" BorderColor="#404040"
BorderStyle="Double" runat="Server">
<asp:Label ID="ShoppingLabel1" Font-Bold="true" Font-Size="20" Text="The Shopping View"
runat="Server" AssociatedControlID="ShoppingView">
</asp:Label>
</asp:Panel>
</asp:View>
</asp:MultiView><br />
<br />
<asp:Label ID="ActivateLabel" BackColor="#ffff66" runat="Server">
</asp:Label><br />
<asp:Label ID="DeactivateLabel" BackColor="#ffff66" runat="Server">
</asp:Label>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!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>
<title>View.Activate Event Example</title>
<script runat="server">
Sub Index_Changed(ByVal Sender As Object, ByVal e As EventArgs)
' Set the active view to
' the view selected by the user.
Dim str As String = ViewListBox.SelectedItem.Text
Select Case (str)
Case "DefaultView"
MultiView1.SetActiveView(DefaultView)
Case "NewsView"
MultiView1.SetActiveView(NewsView)
Case "ShoppingView"
MultiView1.SetActiveView(ShoppingView)
End Select
End Sub
' The handler for the DefaultView's Activate event.
Sub DefaultView_Activate(ByVal sender As Object, ByVal e As EventArgs)
' Notify the user that the event was raised.
ActivateLabel.Text = "The Activate event was raised for the DefaultView."
End Sub
' The handler for the DefaultView's Deactivate event.
Sub DefaultView_Deactivate(ByVal sender As Object, ByVal e As EventArgs)
' Notify the user that the event was raised.
DeactivateLabel.Text = "The Deactivate event was raised for the DefaultView."
End Sub
' The handler for the ShoppingView's Activate event.
Sub ShoppingView_Activate(ByVal sender As Object, ByVal e As EventArgs)
' Notify the user that the event was raised.
ActivateLabel.Text = "The Activate event was raised for the ShoppingView."
End Sub
' The handler for the ShoppingView's Deactivate event.
Sub ShoppingView_Deactivate(ByVal sender As Object, ByVal e As EventArgs)
' Notify the user that the event was raised.
DeactivateLabel.Text = "The Deactivate event was raised for the ShoppingView."
End Sub
' The handler for the NewsView's Activate event.
Sub NewsView_Activate(ByVal sender As Object, ByVal e As EventArgs)
' Notify the user that the event was raised.
ActivateLabel.Text = "The Activate event was raised for the NewsView."
End Sub
' The handler for the NewsView's Deactivate event.
Sub NewsView_Deactivate(ByVal sender As Object, ByVal e As EventArgs)
' Notify the user that the event was raised.
DeactivateLabel.Text = "The Deactivate event was raised for the NewsView."
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not (IsPostBack) Then
MultiView1.SetActiveView(DefaultView)
End If
End Sub
</script>
</head>
<body>
<form id="Form1" runat="server">
<h3>
View Activate and Deactivate Events Example</h3>
<h4>
Select a view to display in a MultiView control:</h4>
<asp:ListBox ID="ViewListBox" Rows="1" SelectionMode="Single" AutoPostBack="True"
OnSelectedIndexChanged="Index_Changed" runat="Server">
<asp:ListItem Value="0">DefaultView</asp:ListItem>
<asp:ListItem Value="1">NewsView</asp:ListItem>
<asp:ListItem Value="2">ShoppingView</asp:ListItem>
</asp:ListBox><br />
<br />
<hr />
<asp:MultiView ID="MultiView1" runat="Server">
<asp:View ID="DefaultView" OnActivate="DefaultView_Activate" OnDeactivate="DefaultView_Deactivate"
runat="Server">
<asp:Panel ID="DefaultPanel1" Width="250px" BackColor="#C0C0FF" BorderColor="#404040"
BorderStyle="Double" runat="Server">
<asp:Label ID="DefaultLabel1" Font-Bold="true" Font-Size="20" Text="The Default View"
runat="Server" AssociatedControlID="DefaultView">
</asp:Label>
</asp:Panel>
</asp:View>
<asp:View ID="NewsView" OnActivate="NewsView_Activate" OnDeactivate="NewsView_Deactivate"
runat="Server">
<asp:Panel ID="NewsPanel1" Width="250px" BackColor="#C0FFC0" BorderColor="#404040"
BorderStyle="Double" runat="Server">
<asp:Label ID="NewsLabel1" Font-Bold="true" Font-Size="20" Text="The News View" runat="Server"
AssociatedControlID="NewsView">
</asp:Label>
</asp:Panel>
</asp:View>
<asp:View ID="ShoppingView" OnActivate="ShoppingView_Activate" OnDeactivate="ShoppingView_Deactivate"
runat="Server">
<asp:Panel ID="ShoppingPanel1" Width="250px" BackColor="#FFFFC0" BorderColor="#404040"
BorderStyle="Double" runat="Server">
<asp:Label ID="ShoppingLabel1" Font-Bold="true" Font-Size="20" Text="The Shopping View"
runat="Server" AssociatedControlID="ShoppingView">
</asp:Label>
</asp:Panel>
</asp:View>
</asp:MultiView><br />
<br />
<asp:Label ID="ActivateLabel" BackColor="#ffff66" runat="Server">
</asp:Label><br />
<asp:Label ID="DeactivateLabel" BackColor="#ffff66" runat="Server">
</asp:Label>
</form>
</body>
</html>
설명
합니다 Deactivate 이벤트가 발생할 때 현재 활성 View 컨트롤이 비활성화 될 합니다.
View 때 컨트롤이 비활성화 될 값을 ActiveViewIndex 속성 변경 또는 SetActiveView 메서드를 호출 하는 지정한 View 컨트롤입니다. 예를 들어 경우 View1
활성 보기 내에서 MultiView 컨트롤는 ActiveViewIndex 속성 변경 내용을 지정 하 View2
, Deactivate 에 대 한 이벤트가 발생 View1
및 Activate 에대한이벤트는View2
.
적용 대상
추가 정보
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET