intellisense on properties of custom objects returned through a web service

Last post 04-25-2007 9:46 PM by alexgav. 7 replies.

Sort Posts:

  • intellisense on properties of custom objects returned through a web service

    04-23-2007, 5:16 PM
    • Participant
      1,969 point Participant
    • Wallym
    • Member since 06-02-2003, 1:10 PM
    • Tennessee
    • Posts 361
    • ASPInsiders
      TrustedFriends-MVPs
    I just setup a quick example to test intellisense on properties of custom
    objects return through a web service. While I am getting some properties, I
    am not getting the properties that I have defined in my object. Will I be
    getting these properties in the future in intellisense?

    Wally
    AJAX Control Toolkit Video: http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2007/01/03/asp-net-podcast-show-81-ajax-control-toolkit.aspx


    Listen to the ASP.NET Podcast @ http://www.aspnetpodcast.com/
  • Re: intellisense on properties of custom objects returned through a web service

    04-23-2007, 9:29 PM
    • Participant
      763 point Participant
    • alexgav
    • Member since 04-07-2005, 8:23 PM
    • Posts 120
    • AspNetTeam

    Wally,

     Could you please share your sample? I can take a look and see why you aren't getting inellisense on your properties.

    Thanks,

    Alex

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: intellisense on properties of custom objects returned through a web service

    04-23-2007, 10:51 PM
    • Participant
      1,969 point Participant
    • Wallym
    • Member since 06-02-2003, 1:10 PM
    • Tennessee
    • Posts 361
    • ASPInsiders
      TrustedFriends-MVPs

    Alex,

    Here is the code for the web service and aspx page.  Is this something I am doing incorrectly? 

    Wally 

     

    using System;
    using System.Linq;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Web.Script.Services;

    /// <summary>
    /// Summary description for OrcasTestWebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    [System.Web.Script.Services.ScriptService]
    public class OrcasTestWebService : System.Web.Services.WebService {

        public OrcasTestWebService () {

            //Uncomment the following line if using designed components
            //InitializeComponent();
        }

        [WebMethod]
        public string HelloWorld() {
            return "Hello World";
        }

        [WebMethod]
        [GenerateScriptType(typeof(DoubleClass))]
        public DoubleClass AddTwoNumbers(double a, double b)
        {
            DoubleClass x = new DoubleClass();
            x.ValueToReturn = a + b;
            return (x);
        }
    }

    public class DoubleClass
    {
        public double ValueToReturn;
    }

    ASPX page:

            <script language="javascript" type="text/javascript">
            function TestJS()
            {
                OrcasTestWebService.AddTwoNumbers(1, 5, SuccessfulCall);
            }
            function SuccessfulCall(result)
            {
                alert(result.ValueToReturn);
            }
            </script>
     

     

  • Re: intellisense on properties of custom objects returned through a web service

    04-24-2007, 3:50 PM
    Answer
    • Participant
      763 point Participant
    • alexgav
    • Member since 04-07-2005, 8:23 PM
    • Posts 120
    • AspNetTeam

    Hi Wally,

    Thank you for posting the sample code. No, you aren't doing anything wrong. I am guessing you were hoping to get "ValueToReturn" in the completion list when you typed "result." in function SuccessfulCall. Unfortunately, currently we do not support this scenario. In order to support such intellisense, runtime should've generated a JScript proxy for the DoubleClass by reflecting over it. While this is theoretically possible, in practice it could be very complex and time consuming because types can be arbitrarily complex (have nested types and such), and in the Orcas timeframe that wasn't feasible. We will look at implementing this in the next version of VS. Sorry I can't give you better news.

    The only other thing I would mention that if we did support this scenario, you probably still would've had to specify <param name="result" type="DoubleClass"></param> to decorate the parameter in SuccessfulCall.

     Thanks,

    Alex

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: intellisense on properties of custom objects returned through a web service

    04-24-2007, 8:12 PM
    • Participant
      1,969 point Participant
    • Wallym
    • Member since 06-02-2003, 1:10 PM
    • Tennessee
    • Posts 361
    • ASPInsiders
      TrustedFriends-MVPs
    Thanks for the info Alex.  I was hoping that I would get something back based on the GenerateSriptType attribute.
     
    Wally
     
    "alexgav" wrote in message news:1680272@forums.asp.net...

    Hi Wally,

    Thank you for posting the sample code. No, you aren't doing anything wrong. I am guessing you were hoping to get "ValueToReturn" in the completion list when you typed "result." in function SuccessfulCall. Unfortunately, currently we do not support this scenario. In order to support such intellisense, runtime should've generated a JScript proxy for the DoubleClass by reflecting over it. While this is theoretically possible, in practice it could be very complex and time consuming because types can be arbitrarily complex (have nested types and such), and in the Orcas timeframe that wasn't feasible. We will look at implementing this in the next version of VS. Sorry I can't give you better news.

    The only other thing I would mention that if we did support this scenario, you probably still would've had to specify <param name="result" type="DoubleClass"></param> to decorate the parameter in SuccessfulCall.

     Thanks,

    Alex



    http://forums.asp.net/1678883/ShowThread.aspx#1680272


    AJAX Control Toolkit Video: http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2007/01/03/asp-net-podcast-show-81-ajax-control-toolkit.aspx


    Listen to the ASP.NET Podcast @ http://www.aspnetpodcast.com/
  • Re: intellisense on properties of custom objects returned through a web service

    04-24-2007, 8:19 PM
    • Participant
      763 point Participant
    • alexgav
    • Member since 04-07-2005, 8:23 PM
    • Posts 120
    • AspNetTeam

    Yes, I know, it would seem you would get more than that, but unfortunately that's not the case. GenerateScriptType does do a little bit - you at least will have DoubleClass in intellisense (if you do Ctrl-J, you will see that it's in there), but there want be any details of the class unfortunately. Again, this is something that we might be able to look at for the next release of VS.

     Thanks,

    Alex

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: intellisense on properties of custom objects returned through a web service

    04-25-2007, 1:53 PM
    • Participant
      1,969 point Participant
    • Wallym
    • Member since 06-02-2003, 1:10 PM
    • Tennessee
    • Posts 361
    • ASPInsiders
      TrustedFriends-MVPs
    I thought about this more this morning.  When I am running in debug mode, I can get the properties and the values of a javascript property.  Since I can get the properties and their values during a debug action, i'm not quite sure why I can't get them in intellisense. *not complaining, just asking*
     
    Wally
     
    "alexgav" wrote in message news:1680571@forums.asp.net...

    Yes, I know, it would seem you would get more than that, but unfortunately that's not the case. GenerateScriptType does do a little bit - you at least will have DoubleClass in intellisense (if you do Ctrl-J, you will see that it's in there), but there want be any details of the class unfortunately. Again, this is something that we might be able to look at for the next release of VS.

     Thanks,

    Alex



    http://forums.asp.net/1680570/ShowThread.aspx#1680571


    AJAX Control Toolkit Video: http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2007/01/03/asp-net-podcast-show-81-ajax-control-toolkit.aspx


    Listen to the ASP.NET Podcast @ http://www.aspnetpodcast.com/
  • Re: intellisense on properties of custom objects returned through a web service

    04-25-2007, 9:46 PM
    Answer
    • Participant
      763 point Participant
    • alexgav
    • Member since 04-07-2005, 8:23 PM
    • Posts 120
    • AspNetTeam

    Sure, it never hurts to ask Smile

    You get better object info in a debugger because by the time you get to it the code actually ran and JScript (in the funky way that it does it) actually dynamically created that property in that object shell that runtime generated for it. At design time, we actually do run JScript code as well to generate some of the intellisense info, but we cannot possibly run it the same way as a user does at runtime. That's why you get better info at runtime through the debugger.

    This posting is provided "AS IS" with no warranties, and confers no rights.
Page 1 of 1 (8 items)