_XDocument4.NotifyHost 方法 (String)

为主机应用程序或 ASPX 页提供自定义值。

命名空间:  Microsoft.Office.Interop.InfoPath.SemiTrust
程序集:  Microsoft.Office.Interop.InfoPath.SemiTrust(位于 Microsoft.Office.Interop.InfoPath.SemiTrust.dll 中)

语法

声明
Sub NotifyHost ( _
    bstrNotification As String _
)
用法
Dim instance As _XDocument4
Dim bstrNotification As String

instance.NotifyHost(bstrNotification)
void NotifyHost(
    string bstrNotification
)

参数

  • bstrNotification
    类型:System.String

    将由主机应用程序或 ASPX 页中的代码使用的自定义值。

实现

_XDocument3.NotifyHost(String)

备注

当在 ASPX 页上的 Microsoft.Office.InfoPath.Server.Controls.XmlFormView 控件中承载 InfoPath 表单模板时,并且该 ASPX 页从带有 InfoPath Forms Services 的 Microsoft SharePoint Server 2010 中运行时,将使用 NotifyHost 方法。为 notification 参数提供的值是一个字符串,宿主 ASPX 页的代码隐藏技术可以使用该字符串来执行自定义操作。

有关在 ASPX 页中承载 InfoPath 表单模板的信息,请参阅 MSDN 上 InfoPath 开发人员门户(该链接可能指向英文页面)中标题为"在自定义 Web 表单中承载 InfoPath 表单编辑环境"的文章。

当 InfoPath 应用程序自身作为控件驻留在另一个应用程序中时,也可以使用 NotifyHost 方法,但是在这种情况下通常使用 Host 属性来检索与主机应用程序的对象模型一起使用的自定义对象。

有关在另一个应用程序中以控件形式承载 InfoPath 的信息,请参阅 MSDN 上 InfoPath 开发人员门户(该链接可能指向英文页面)上标题为"在自定义 Web 表单中承载 InfoPath 2007 表单编辑环境"的文章。

由于 Microsoft InfoPath 无法识别 NotifyHost 方法,因此您必须声明此方法并将其转换成 _XDocument4 类型才能访问此方法。有关详细信息,请参阅如何:使用与 InfoPath 2003 不兼容的 Microsoft.Office.Interop.InfoPath.SemiTrust 成员

重要

此成员只能由与当前打开的表单在相同域中运行的表单访问,或者由已授予跨域权限的表单访问。

示例

以下示例演示为了接收由 NotifyHost 方法提供的字符串值,应如何编写 ASPX 页代码隐藏技术的事件处理程序。在此示例中,NotifyHost 方法将提供"ActionA"作为 bstrNotification 参数,而事件处理程序将在接收到该值时执行有条件的操作。

private void XmlFormView1_NotifyHost(Object sender, 
   NotifyHostEventArgs e)
{
   if (e.Notification == "ActionA")
   {
      // Code to perform if 'ActionA' is received.
   }

   else 
   {
      // Code to perform an alternative action.
   }
}
Private Sub XmlFormView1_NotifyHost(sender As Object, _
   e As NotifyHostEventArgs)
   If (e.Notification = "ActionA") Then
      ' Code to perform if 'ActionA' is received.
   Else 
      ' Code to perform an alternative action.
   End If
End Sub

另请参阅

引用

_XDocument4 接口

_XDocument4 成员

NotifyHost 重载

Microsoft.Office.Interop.InfoPath.SemiTrust 命名空间