Hi Paul,

From the existence of main.fs, I take that you are using WebSharper 1.0 and not the recently announced WebSharper 2.0 Beta. This makes no difference in your case since you are using the ASP.NET template, but you may also be interested in the MVC and the Sitelet templates that ship with WebSharper 2.0.

OK - now onto the problem. Working with the ASP.NET templates, there are a couple important points to remember:

1) Web.Config defines a default tag prefix (ws:) and maps that tag prefix to the WebSharperProject namespace. So unless you change this manually or add additional tag prefixes, you must put your F# code in this namespace.

2) Your F# code has to provide a type that wraps your pagelet into a Web.Control instance so you can embed it into ASPX markup.

3) Your ASPX markup then should use the right tag prefix with the right control name.

So, all in all, if you take the default ASP.NET WebSharper template (1.0) and want to update it with the CanvasAnimation demo, then you need to do the following:

1) Add a WebSharperProject namespace and a top-level module, and paste the sample code from the website *under* this module. So you should have something like this:

1
2
3
4
5
6
namespace WebSharperProject

open IntelliFactory.WebSharper

module CanvasAnimation =
    [...the sample pasted *without* the namespace...]

2) then add a Web.Control wrapper type for this to the WebSharperProject namespace (so outside of the CanvasAnimation module):

1
2
3
4
5
6
7
[<JavaScriptType>]

type CanvasAnimationControl() = 
    inherit Web.Control()

    [<JavaScript>]
    override this.Body = CanvasAnimation.Main ()

3) Change the ASPX file to reference your new type:

1
    <ws:CanvasAnimationControl runat="server"/>

Hope this helps.

Cheers,

Adam.

By on 12/8/2010 11:01 AM ()

Hi Adam,

Many thanks, that was an excellent set of clear instructions that worked first time and clarified matters greatly.

I really appreciate you taking your time to help me.

Cheers,

Paul.

By on 12/9/2010 8:06 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