Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handler doesn't bind to action template hole (C#) #191

Open
V0d01ey opened this issue Sep 11, 2018 · 0 comments
Open

Handler doesn't bind to action template hole (C#) #191

V0d01ey opened this issue Sep 11, 2018 · 0 comments
Assignees

Comments

@V0d01ey
Copy link

V0d01ey commented Sep 11, 2018

Binding a handler to ws-onclick hole results in exception "Invalid hole, expected quoted event: ".

<button id="sendUT" type="button" ws-onclick="sendUTClick">Add</button>
    public class Server
    {
...
        [Website]
        public static Sitelet<object> Main =>
            new SiteletBuilder()
                .With<Home>((ctx, action) =>
                    Page(ctx, action, "Home",
                        doc(
                            h1("Say Hi to the server!"),
                            div(client(() => Client.Main())), 
                            new Template.Uploaddialogtemplate()
                                .sendUTClick((tev) => Client.SendUTClickHandler(tev))   // <--  assigning method to handler-hole
                                .Elt()
                        )
                    )
                )
                .With<About>((ctx, action) =>
                    Page(ctx, action, "About",
                        doc(
                            h1("About"),
                            p("This is a template WebSharper client-server application.")
                        )
                    )
                )
                .Install();
    }


    [JavaScript]
    public static class Client
    {
...
        static public void SendUTClickHandler(WebSharper.UI.Templating.Runtime.Server.TemplateEvent<Template.Uploaddialogtemplate.Vars, WebSharper.JavaScript.Dom.MouseEvent> tev)
        {            
            JS.Alert("test");
        }
    }

Stack trace of the exception on startup.

[Exception: Invalid hole, expected quoted event: sendUTClick]
   [email protected](String message) +46
   WebSharper.UI.Templating.Runtime.Server.writeElement@368(FSharpOption`1 name, Boolean keepUnfilled, FSharpOption`1 inlineBaseName, Dictionary`2 requireResources, Boolean plain, FSharpList`1 extraAttrs, RenderContext ctx, Boolean isRoot, Boolean plain@368-1, String tag, Attr[] attrs, FSharpOption`1 wsVar, Node[] children) +224
   [email protected](Node _arg8) +197
   WebSharper.UI.Templating.Runtime.Server.writeElement@368(FSharpOption`1 name, Boolean keepUnfilled, FSharpOption`1 inlineBaseName, Dictionary`2 requireResources, Boolean plain, FSharpList`1 extraAttrs, RenderContext ctx, Boolean isRoot, Boolean plain@368-1, String tag, Attr[] attrs, FSharpOption`1 wsVar, Node[] children) +730
   [email protected](Node _arg8) +197
   WebSharper.UI.Templating.Runtime.Server.writeTemplate@308(FSharpOption`1 name, Boolean keepUnfilled, FSharpOption`1 inlineBaseName, Dictionary`2 requireResources, Template template, Boolean plain, FSharpList`1 extraAttrs, RenderContext ctx) +195
   [email protected](Context ctx, HtmlTextWriter w, Boolean r) +400
   WebSharper.UI.Elt.Write(Context ctx, HtmlTextWriter h, FSharpOption`1 res) +43
   <StartupCode$WebSharper-UI>[email protected](Doc d) +32
   Microsoft.FSharp.Primitives.Basics.List.iter(FSharpFunc`2 f, FSharpList`1 x) +38
   [email protected](Node _arg8) +902
   WebSharper.UI.Templating.Runtime.Server.writeElement@368(FSharpOption`1 name, Boolean keepUnfilled, FSharpOption`1 inlineBaseName, Dictionary`2 requireResources, Boolean plain, FSharpList`1 extraAttrs, RenderContext ctx, Boolean isRoot, Boolean plain@368-1, String tag, Attr[] attrs, FSharpOption`1 wsVar, Node[] children) +730
   [email protected](Node _arg8) +197
   WebSharper.UI.Templating.Runtime.Server.writeElement@368(FSharpOption`1 name, Boolean keepUnfilled, FSharpOption`1 inlineBaseName, Dictionary`2 requireResources, Boolean plain, FSharpList`1 extraAttrs, RenderContext ctx, Boolean isRoot, Boolean plain@368-1, String tag, Attr[] attrs, FSharpOption`1 wsVar, Node[] children) +730
   [email protected](Node _arg8) +197
   WebSharper.UI.Templating.Runtime.Server.writeElement@368(FSharpOption`1 name, Boolean keepUnfilled, FSharpOption`1 inlineBaseName, Dictionary`2 requireResources, Boolean plain, FSharpList`1 extraAttrs, RenderContext ctx, Boolean isRoot, Boolean plain@368-1, String tag, Attr[] attrs, FSharpOption`1 wsVar, Node[] children) +730
   [email protected](Node _arg8) +197
   WebSharper.UI.Templating.Runtime.Server.writeTemplate@308(FSharpOption`1 name, Boolean keepUnfilled, FSharpOption`1 inlineBaseName, Dictionary`2 requireResources, Template template, Boolean plain, FSharpList`1 extraAttrs, RenderContext ctx) +195
   [email protected](Context ctx, HtmlTextWriter w, Boolean r) +400
   WebSharper.UI.Elt.Write(Context ctx, HtmlTextWriter h, Boolean res) +83
   [email protected](HtmlTextWriter tw) +112
   <StartupCode$WebSharper-Sitelets>[email protected](FSharpOption`1 doctype, FSharpOption`1 title, FSharpFunc`2 writeHead, FSharpFunc`2 writeBody, HtmlTextWriter writer) +277
   [email protected](Stream stream) +411
   [email protected](Response response) +298
   [email protected](a a) +87
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   Microsoft.FSharp.Control.AsyncIAsyncResult`1.GetResult() +309
   Microsoft.FSharp.Control.AsBeginEndHelpers.endAction(IAsyncResult iar) +80
   System.Web.CallHandlerExecutionStep.InvokeEndHandler(IAsyncResult ar) +212
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +166
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants