Step 1: Using the NotifyHost Method to Send Notifications
You can use the NotifyHost method of the XmlForm class to send notifications to the hosting environment of a form template. Perform the following steps to add a Button control and its event handler to a form template, and call the NotifyHost method:
1.Open the InfoPath browser-compatible form template in design mode.
2.In the task pane, click Controls.
3.Add a Button control to the form template.
4.Right-click the Button control and select Button Properties.
5.On the Button Properties dialog box, click Edit Form Code to add a Clicked event handler to the form template’s business logic code.
6.Add the following code to the Button control’s Clicked event handler:
Code To add
NotifyHost("Message from InfoPath");
Step 2: Hooking Up the NotifyHost Event to an Event Handler
1. Open the FormServer.aspx from C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS
2. Add following code in FormServer.aspx after the page register tag
3. Publish the form