Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open IntelliFactory.WebSharper
- open IntelliFactory.WebSharper.Sitelets
- module FormletSnippets =
- open IntelliFactory.WebSharper.Formlet
- open IntelliFactory.WebSharper.Html
- [<JavaScript>]
- let Snippet1 = Controls.Input "initial value"
- [<JavaScript>]
- let RunInBlock title f formlet =
- let output = Div []
- formlet
- |> Formlet.Run (fun res -> let elem = f res in output -< [ elem ] |> ignore)
- |> fun form ->
- Div [Attr.Style "float:left;margin-right:20px;width:300px;min-height:200px;"] -< [
- H5 [Text title]
- Div [form]
- output
- ]
- [<JavaScript>]
- let RunSnippet title formlet =
- formlet |> RunInBlock title (fun s -> Div [ P ["You entered: " + s |> Text] ])
- module Formlets =
- open FormletSnippets
- open IntelliFactory.WebSharper.Html
- type Snippets() =
- inherit Web.Control()
- [<JavaScript>] override this.Body = Div [ RunSnippet "Snippet1" Snippet1 ] :> _
- module VariousFormletSnippets =
- open IntelliFactory.Html
- open IntelliFactory.WebSharper.Sitelets
- type Action = | Home
- module Pages =
- let SnippetsPage =
- Content.PageContent <| fun ctx ->
- { Page.Default with
- Title = Some "Formlet snippets"
- Body =
- [
- H1 [Text "Snippets"]
- Div [new Formlets.Snippets()]
- ]
- }
- let EntireSite =
- Sitelet.Content "/" Action.Home Pages.SnippetsPage
- type Website() =
- interface IWebsite<Action> with
- member this.Sitelet = EntireSite
- member this.Actions = []
- type Global() =
- inherit System.Web.HttpApplication()
- member g.Application_Start(sender: obj, args: System.EventArgs) =
- ()
- [<assembly: Website(typeof<VariousFormletSnippets.Website>)>]
- do ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement