If you have ever developed a custom ASPX page that uses an XmlFormView control to host InfoPath functionality, then you are probably familiar with the message that appears after the form is submitted.

Often, it makes sense to have users redirected to a different Web page, rather than having them see the generic text within the XmlFormView control. Fortunately, there is a simple solution to this requirement. Within your ASPX page, you can specify an OnClose event handler for your control. The following example shows how to specify this event by using the OnClose attribute for the cc1:XmlFormView element.

<form id="form1" runat="server" enctype="multipart/form-data">
        <cc1:XmlFormView ID="XmlFormView1" runat="server" Height="500px" Width="100%" XsnLocation="http://moss.litwareinc.com/sample/forms/template.xsn" EditingStatus="Editing" OnClose="_xmlFormView1_OnClose"/>

Then, within the corresponding code file, you would just need to add that event handler with an instruction to redirect to a different Web page. The following example shows how a static redirection can be done in C#.

protected void _xmlFormView1_OnClose(object sender, EventArgs e)

Many thanks to Boris Rivers-Moore for quickly pointing me to the OnClose event. Incidentally, Boris co-authored the technical article Hosting the InfoPath 2007 Form Editing Environment in a Custom Web Form, a good source for getting started with these types of solutions.