what is the difference between following methods ...

53 views
Skip to first unread message

Mutiullah Haider

unread,
Sep 26, 2011, 4:05:03 PM9/26/11
to WebSharper

Hi all,

I am new to this forum.

what is the difference between following methods ... ? Can someone
explain a little in detail.

Thanks.


-
- IntelliFactory.WebSharper.Html.Tag.P ;;
val it : (seq<#Html.INode> -> Html.Element) = <fun:clo@238-7>
>
-
- IntelliFactory.Html.Tags.P ;;
val it :
(seq<#IntelliFactory.Html.Html.INode<'b>> ->
IntelliFactory.Html.Html.Element<'b>) = <fun:clo@241-8>
>




and here is the output

- IntelliFactory.WebSharper.Html.Tag.P [] ;;
val it : Html.Element =
IntelliFactory.WebSharper.Html.Element {Dom = null;
Html = "";
Id = ?;
Item = ?;
JQuery = null;
Text = "";
Value = null;
Values = [|null|];}


- IntelliFactory.Html.Tags.P [] ;;

IntelliFactory.Html.Tags.P [] ;;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\stdin(335,1): error FS0030: Value restriction. The value 'it' has
been in
ed to have generic type
val it : IntelliFactory.Html.Html.Element<'_a>
Either define 'it' as a simple data term, make it a function with
explicit a
ents or, if you do not intend for it to be generic, add a type
annotation.

Anton Tayanovskyy

unread,
Sep 26, 2011, 4:21:16 PM9/26/11
to websh...@googlegroups.com
Hi Mutiullah,

Welcome to the group.

There are currently two ways to construct HTML in WebSharper. One is
to generate it on the server, usually in the context of a sitelet.
This HTML appears in your browser as you click View Source. The other
way is to construct DOM nodes that are appended dynamically in
JavaScript.

In fact, your code always executes in one of the two contexts: either
on the server, or on the client.

IntelliFactory.Html.* contains combinators for server-side HTML generation.
IntelliFactory.WebSharper.Html.* contains combinators for client-side
HTML generation, constructing DOM nodes.

This sample, among others, demonstrates the use of the client-side combinators:

http://websharper.com/samples/HelloWorld

To bridge the two worlds, server and client, one defines controls.
Following the example:

type HelloWorldViewer() =
inherit Web.Control()
[<JavaScript>]
override this.Body = HelloWorld.Main () :> _

Now this control can be embedded into the server-side HTML, as in `Div
[new HelloWorldViewer()]`. What happens then is the server emits a
placeholder, say `<div id="ws1"/>`, and the client on JavaScript
startup runs `HelloWorld.Main` in JavaScript, produces some DOM nodes
and replaces the placeholder.

Hope it helps, and you are welcome to ask further questions.


Thanks,

Anton

--
Kind Regards,
Anton Tayanovskyy

WebSharper™ - type-safe JavaScript in F#
http://intellifactory.com

Mutiullah Haider

unread,
Sep 26, 2011, 4:33:11 PM9/26/11
to WebSharper

Anton,

Thanks for a quick response and very detailed explanation. I would
never figure that out by myself .

Really appreciated.

Thanks again. :)


On Sep 26, 4:21 pm, Anton Tayanovskyy <anton.tayanovs...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages