开发者

Custom action after sending Infopath form

开发者 https://www.devze.com 2023-03-28 20:12 出处:网络
I\'m using a browser-enabled Infopath form with Sharepoint 2010 and I want to show a modal开发者_Go百科 popup or even redirect to another page after clicking on Submit, saying \"Thank you... Your form

I'm using a browser-enabled Infopath form with Sharepoint 2010 and I want to show a modal开发者_Go百科 popup or even redirect to another page after clicking on Submit, saying "Thank you... Your form has been sent...".

I can't use a View (and change to that view on submit) because the form is inside a 'tab' in the page. I mean, the page contains 5 DIVs acessible through 5 buttons. The DIV which is open by default is the 1st one. The form is inside the 5th DIV. After the submit action (postback) the page reloads and the 1st DIV is shown, so the user can't see the View with "Thank you...."

Any ideias on how to solve this? Thanks in advance!

EDIT 2

I tried Andreas' solution but didn't work. This is my "submit" button code.

    public void CTRL114_5_Clicked(object sender, ClickedEventArgs e)
            {

             try
             {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    this.Submit();                             
                    HttpContext.Current.Response.Redirect("ThankYou.aspx");
                });
             } catch (Exception ex)
             {
                  System.Console.Write(ex.toString());
             }

            }

When I click on Submit, nothing happens. No page redirection, no view switching, no data submitting. Any ideas? Thank you!


Popup's do not work with browser-enabled forms, your only possibility will be custom code. In your submit code, you can do a redirect to a static thank you page.

HttpContext.Current.Response.Redirect("ThankYou.aspx");

Edit: In your VSTA Editor, make sure you have System.Web referenced. Without an actual exception it's really hard to say what's not working. Try the following code and post the output please -

try
{
     SPSecurity.RunWithElevatedPrivileges(delegate()
     {
           this.Submit();
           HttpContext.Current.Response.Redirect("ThankYou.aspx");
     });
}
catch(Exception ex)
{
     //implement your logging logic here
}

Edit 2: Can you open the form in preview mode and debug the code? Also consider changing your logging code to something like this:

catch(Exception ex)
{
     using(var writer = new StreamWriter(@"C:\log.txt",true))
        writer.WriteLine("{0}\t{1}", DateTime.Now, ex.Message);
}

because Console.WriteLine does not work with InfoPath and you never get hold of the actual exception. I'm afraid without a error messsage it will be quite hard to troubleshoot your issue any further.


Another way of redirecting is using the 'Source' parameter of the query string. It is, however, only possible to redirect to pages in the same site collection as the form. E.g.

http://[site]/_layouts/FormServer.aspx?XsnLocation=/sites/[site]/formservertemplates/[form].xsn<b>&Source=/sites/[site]/pages/[page]</b>

If ThankYou.aspx is outside the current site colleciton, you can redirect to a intermediary page which redirects to ThankYou.aspx. I have heard of no other way to bypass this.

0

精彩评论

暂无评论...
验证码 换一张
取 消