How do you integrate Websharper with an existing ASP.NET MVC project? -


the websharper website has tutorial on integrating asp.net websharper, vague on things. have installed websharper package on asp.net mvc project , followed step 1 of instructions, i'm confused rest.

for step 2, or how add websharper application want integrate? add f# source file in scripts folder , have automatically generate javascript need? or have compile in separate websharper project , add generated javascript asp.net mvc project?

in title itself, says integration aspx pages. mean won't work razor web pages, default asp.net mvc?

inserting websharper controls inside razor pages indeed not easy released websharper, working on helpers facilitate this, released soon. work in progress available here. relies on latest websharper, need build both source if want use right now.

here need (subject slight changes before release websharper.aspnetmvc):

  • reference websharper, websharper.aspnetmvc , websharper project web project.
  • if use rpc and/or sitelets:

    • add relevant module(s) web.config shown in documentation linked;
    • add filterconfig.registerglobalfilters:

      filters.add(new websharper.aspnetmvc.filter()); 
  • to use client-side controls:

    • in main razor layout, inside head tag, add following:

      @websharper.aspnetmvc.scriptmanager.head() 

      this contain css , javascript tags required controls.

    • to insert control in view, first create @ top of view:

      @{     var mycontrol = websharper.aspnetmvc.scriptmanager.register(new mycontrol()); } 

      and can insert in view, eg:

      <div>     <h1>my control:</h1>     @mycontrol </div> 

      it important create control before view starts rendering, or else scriptmanager.head() have been rendered without control's dependencies.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -