WebPartManager.CloseProviderWarning 属性
定义
获取或设置一个警告,用户关闭在连接中充当其他控件的提供者的控件时,会显示该警告。Gets or sets a warning that is displayed when a user closes a control that is acting as a provider to other controls in a connection.
public:
virtual property System::String ^ CloseProviderWarning { System::String ^ get(); void set(System::String ^ value); };
public virtual string CloseProviderWarning { get; set; }
member this.CloseProviderWarning : string with get, set
Public Overridable Property CloseProviderWarning As String
属性值
一个包含警告消息的字符串。A string that contains the warning message. 默认值是一条由 .NET Framework 提供的、特定于区域性的消息。The default is a culture-specific message supplied by the .NET Framework.
示例
下面的代码示例演示如何使用 CloseProviderWarning 属性向用户显示自定义警告。The following code example demonstrates how to use the CloseProviderWarning property to display a custom warning to users.
此代码示例包含四个部分:The code example has four parts:
使您能够在 Web 部件页上更改显示模式的用户控件。A user control that enables you to change display modes on a Web Parts page.
包含两个自定义 WebPart 控件和自定义接口的源代码文件。A source code file that contains two custom WebPart controls and a custom interface.
一个网页,其中包含两个 WebPart 可以连接的自定义控件和一个
<asp:webpartmanager>元素。A Web page that contains two custom WebPart controls that can be connected and an<asp:webpartmanager>element.说明如何在浏览器中工作。An explanation of how the example works in a browser.
下面的代码仅包含示例的网页部分。The following code contains only the Web page portion of the example. 还需要为上述自定义控件提供自定义用户控件和源代码。You will also need the custom user control and the source code for the custom controls mentioned above. 从类概述的 "示例" 部分获取这两个项 WebPartManager 。Obtain these two items from the Example section of the WebPartManager class overview.
以下网页代码演示了如何在元素中的声明性标记中将自定义警告消息分配给 CloseProviderWarning 属性 <asp:webpartmanager> 。The following Web page code demonstrates how to assign a custom warning message to the CloseProviderWarning property in declarative markup in the <asp:webpartmanager> element.
<%@ Page Language="C#" %>
<%@ register TagPrefix="uc1"
TagName="DisplayModeMenuCS"
Src="DisplayModeMenuCS.ascx" %>
<%@ register tagprefix="aspSample"
Namespace="Samples.AspNet.CS.Controls"
Assembly="ConnectionSampleCS" %>
<!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 id="Head1" runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<!-- Reference the WebPartManager control. -->
<asp:WebPartManager ID="WebPartManager1" runat="server"
CloseProviderWarning="You are closing a provider control." />
<div>
<uc1:DisplayModeMenuCS ID="displaymode1" runat="server" />
<!-- Reference consumer and provider controls in a zone. -->
<asp:WebPartZone ID="WebPartZone1" runat="server">
<ZoneTemplate>
<aspSample:ZipCodeWebPart ID="zip1"
runat="server"
Title="Zip Code Control"/>
<aspSample:WeatherWebPart ID="weather1"
runat="server"
Title="Weather Control" />
</ZoneTemplate>
</asp:WebPartZone>
<hr />
<!-- Add a ConnectionsZone so users can connect controls. -->
<asp:ConnectionsZone ID="ConnectionsZone1" runat="server" />
</div>
</form>
</body>
</html>
<%@ Page Language="vb" %>
<%@ register TagPrefix="uc1"
TagName="DisplayModeMenuVB"
Src="DisplayModeMenuVB.ascx" %>
<%@ register tagprefix="aspSample"
Namespace="Samples.AspNet.VB.Controls"
Assembly="ConnectionSampleVB" %>
<!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 id="Head1" runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<!-- Reference the WebPartManager control. -->
<asp:WebPartManager ID="WebPartManager1" runat="server"
CloseProviderWarning="You are closing a provider control." />
<div>
<uc1:DisplayModeMenuVB ID="displaymode1" runat="server" />
<!-- Reference consumer and provider controls in a zone. -->
<asp:WebPartZone ID="WebPartZone1" runat="server">
<ZoneTemplate>
<aspSample:ZipCodeWebPart ID="zip1"
runat="server"
Title="Zip Code Control"/>
<aspSample:WeatherWebPart ID="weather1"
runat="server"
Title="Weather Control" />
</ZoneTemplate>
</asp:WebPartZone>
<hr />
<!-- Add a ConnectionsZone so users can connect controls. -->
<asp:ConnectionsZone ID="ConnectionsZone1" runat="server" />
</div>
</form>
</body>
</html>
在浏览器中加载网页后,请单击 " 显示模式 " 下拉列表控件,然后选择 " 连接 ",将页面切换到连接模式。After you have loaded the Web page in a browser, click the Display Mode drop-down list control and select Connect to switch the page to connect mode. 连接模式使用 <asp:connectionszone> 元素使您能够在控件之间创建连接。Connect mode uses the <asp:connectionszone> element to enable you to create connections between controls. 在连接模式下,单击 邮政编码 控件标题栏中的向下箭头以激活其谓词菜单,然后单击 " 连接"。In connect mode, click the downward arrow in the title bar of the ZIP Code control to activate its verbs menu, and then click Connect. 连接用户界面 (UI) 出现后,单击 " 创建使用者的连接 " 链接。After the connection user interface (UI) appears, click the Create a connection to a Consumer link. 出现包含下拉列表控件的单元格。A cell appears that has a drop-down list control. 在下拉列表中选择 " 天气控制 ",然后单击 " 连接 " 完成两个控件的连接。Select Weather Control in the drop-down list, and click Connect to complete the connection of the two controls. 单击 " 关闭",然后使用 " 显示模式 " 下拉列表将页面恢复到正常浏览模式。Click Close, and then use the Display Mode drop-down list to return the page to normal browse mode. 最后,单击 邮政编码 控件的谓词菜单 (这是此示例中的提供程序控件) 并选择 " 关闭"。Finally, click the verbs menu for the ZIP Code control (which is the provider control in this case) and select Close. 随即显示您分配给该属性的自定义消息 CloseProviderWarning 。The custom message you assigned to the CloseProviderWarning property is displayed.
注解
当用户关闭控件时 WebPart ,通常不会显示任何消息。When a user closes a WebPart control, normally no message is displayed. 有关关闭控件的方法的详细信息,请参阅 CloseWebPart 方法。For more information about what it means to close a control, see the CloseWebPart method.
但是,当控件连接到其他控件并作为数据的提供程序时,当用户尝试关闭控件时,将显示默认警告消息。However, when a control is connected to another control and is acting as a provider of data to the other control, a default warning message is displayed when a user attempts to close the control. 消息告知用户提供程序控件即将关闭,这意味着以使用者身份连接到此提供程序的控件将不再具有任何要使用的数据。The message tells users that a provider control is about to close, which means that controls connected to this provider as consumers will no longer have any data to consume. CloseProviderWarning属性使开发人员可以自定义向用户显示的警告消息。The CloseProviderWarning property enables developers to customize the warning message that is displayed to the user.
如果页面开发人员将空或空字符串值分配给此属性,则当用户关闭作为提供者的控件时,将不会显示任何警告消息框 WebPart 。If a page developer assigns an empty or null string value to this property, no warning message box will be shown when a user closes a WebPart control that is a provider.