4 people like it.

WebSharper Hello World

This sample implements "Hello, world!" as a WebSharper application. It demonstrates how to compose HTML/XML using combinators, how to dynamically create a button with a handler and how to update an existing DOM element.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
// The example is copied from the official WebSharper documentation:
// http://www.websharper.com/samples/HelloWorld
namespace Samples

open IntelliFactory.WebSharper
open IntelliFactory.WebSharper.Html

module HelloWorld =

    [<JavaScript>]
    let Main () =
        let welcome = P [Text "Welcome"]
        Div [
            welcome
            Button [Text "Click Me!"]
            |>! OnClick (fun e args ->
                welcome.Text <- "Hello, world!")
        ]

type HelloWorldViewer[<JavaScript>]() =
    inherit Web.Control()

    [<JavaScript>]
    override this.Body = HelloWorld.Main () :> Html.IPagelet
val Main : unit -> 'a

Full name: Samples.HelloWorld.Main
val welcome : obj
Multiple items
type HelloWorldViewer =
  inherit obj
  new : unit -> HelloWorldViewer
  override Body : 'a

Full name: Samples.HelloWorldViewer

--------------------
new : unit -> HelloWorldViewer
namespace Microsoft.FSharp.Control
override HelloWorldViewer.Body : 'a

Full name: Samples.HelloWorldViewer.Body
module HelloWorld

from Samples
Raw view New version

More information

Link:http://fssnip.net/4R
Posted:6 years ago
Author:Tomas Petricek
Tags: web , websharper , dom , html