Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jesper Hauge 298 posts 487 karma points c-trib
    Jun 26, 2009 @ 15:46
    Jesper Hauge
    0

    Make webservice available from datatype javascript

    I've got a usercontrol that relies on a webservice accessible in javascript via a scriptmanager. Now I'd like to use this usercontrol as a datatype via the umbraco usercontrol wrapper.

    I can't put another ScriptManager in the usercontrol since it cannot have a form tag. Is there some way of adding this webservice to a scriptmanager in Umbraco?

    Regards
    .Hauge

  • fed 199 posts 70 karma points
    Jun 26, 2009 @ 15:56
    fed
    0

    Could this be a possible solution:

    if (ScriptManager.GetCurrent(Page) == null) {
        ScriptManager scp = new ScriptManager();
        Page.Controls.Add(scp);
    }

    Don't know if I misunderstood you..

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jun 26, 2009 @ 16:01
    Richard Soeteman
    100

    Hi Jesper,

    Can't you use the ScriptManager</span></span><span style="font-size: x-small;"><span style="color: #000000;">.GetCurrent Method? </span></span>

    I've used this code in a usercontrol to register a Webservice that can be used from Javascript

     

     

     ScriptManager</span></span><span style="font-size: x-small;"> sm = </span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">ScriptManager</span></span><span style="font-size: x-small;">.GetCurrent(Page);<font size="2">

    sm.EnablePageMethods =

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jun 26, 2009 @ 16:03
    Richard Soeteman
    0

    Sorry about the messed up code, Below a copy using notepad first.

    ScriptManager sm = ScriptManager.GetCurrent(Page);
    sm.EnablePageMethods = true;
    ServiceReference legacyPath = new ServiceReference(GlobalSettings.Path + "/webservices/DocumentFolder.asmx");

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jun 26, 2009 @ 16:06
    Richard Soeteman
    0

    Still a bit sleepy forgot the last part to actual register the service

    ScriptManager sm = ScriptManager.GetCurrent(Page);
    sm.EnablePageMethods = true;
    ServiceReference legacyPath = new ServiceReference(GlobalSettings.Path + "/webservices/DocumentFolder.asmx");

    if (!sm.Services.Contains(legacyPath))
                    sm.Services.Add(legacyPath);

  • Jesper Hauge 298 posts 487 karma points c-trib
    Jun 26, 2009 @ 16:25
    Jesper Hauge
    0

    Just to wrap this up: Richards suggestion was spot on, code is posted below, in a hopefully more legible writing.

    protected void Page_Load(object sender, EventArgs e) {
      ScriptManager sm = ScriptManger.GetCurrent(Page);
      ServiceReference sr = new ServiceReference("~/usercontrols/MyService.asmx");
      sm.Services.Add(sr);
    }

    Thanks a lot, Richard

    .Hauge

Please Sign in or register to post replies

Write your reply to:

Draft