共用方式為


_XDocument3.NotifyHost 方法

將自訂值提供給主控應用程式或 ASPX 頁面。

**命名空間:**Microsoft.Office.Interop.InfoPath
**組件:**Microsoft.Office.Interop.InfoPath (於 microsoft.office.interop.infopath.dll 中)

語法

'宣告
<DispIdAttribute(58)> _
Sub NotifyHost ( _
    <InAttribute> bstrNotification As String _
)
'用途
Dim instance As _XDocument3
Dim bstrNotification As String

instance.NotifyHost(bstrNotification)
[DispIdAttribute(58)] 
void NotifyHost (
    [InAttribute] string bstrNotification
)

參數

  • bstrNotification
    將會由主控應用程式或 ASPX 頁面中之程式碼所使用的自訂值。

備註

NotifyHost 方法是要在 InfoPath 表單範本於 ASPX 頁面上之 Microsoft.Office.InfoPath.Server.Controls.XmlFormView 控制項內主控的情況下使用 (此 ASPX 頁面是在 Microsoft Office Forms Server 2007 上執行或是從搭配 InfoPath Forms Services 的 Microsoft Office SharePoint Server 2007 執行)。您為 notification 參數提供的值是一個字串,ASPX 主控頁面的程式碼後置可使用這個字串來執行自訂動作。

如需在 ASPX 頁面上裝載 InfoPath 表單範本的詳細資訊,請參閱 MSDN 上 InfoPath Developer Portal 中的<Hosting the InfoPath 2007 Form Editing Environment in a Custom Web Form>文章。

在另一個應用程式中將 InfoPath 應用程式本身當做控制項裝載時,也可以使用 NotifyHost 方法,雖然在這種情況下,您通常會使用 Host 屬性擷取自訂物件來搭配主應用程式的物件模型一起運作。

如需以控制項的形式將 InfoPath 裝載於另一個應用程式的詳細資訊,請參閱 MSDN 上 InfoPath Developer Portal 中的<Hosting the InfoPath 2007 Form Editing Environment in a Custom Web Form>文章。

範例

下列範例會示範 ASPX 頁面之程式碼後置內的事件處理常式應有的內容,以便接收 NotifyHost 方法所提供的字串值。在此範例中,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

請參閱

參考

_XDocument3 介面
_XDocument3 成員
Microsoft.Office.Interop.InfoPath 命名空間