In general, redirection should be done using the JavaScript redirect version. If you want to make an RPC call after the formlet is ready, you can do:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// assuming this function:
[<Rpc>]
let myRP data : async<unit> = ...

// this is in a JavaScript region:
let myFormlet : Formlet<unit> = ...
let myFormletWithRPCAndRedirect =
    Formlet.Do {
        let! data = myFormlet
        
        Async.Start (myRP data)

        redirect "..."

        return ()
    }

Or if you want to wait for the RPC result before redirecting:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// assuming this function:
[<Rpc>]
let myRP data : async<bool> = ...

// this is in a JavaScript region:
let myFormlet : Formlet<_> = ...
let myFormletWithRPCAndRedirect =
    Formlet.Do {
        let! data = myFormlet
        
        async {
            let! success = myRP data
            if success then redirect "..."
        }
        |> Async.Start

        return ()
    }
By on 1/30/2012 4:03 AM ()

Thank you Ramon!

By on 1/30/2012 4:21 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper