views:

752

answers:

3

I've finally got Intellisense working for JQuery by applying patch KB958502 to Visual Studio 2008 and including this line:

/// <reference path="JQuery\jquery-1.3.2.js"/>

at the top of my .js files. Now I'm trying to figure out how to get JavaScript intellisense for the client proxies generated by the ScriptManager's ScriptReference elements (as shown here):

    <asp:ScriptManager ID="ScriptManager1" runat="Server" EnablePartialRendering="false" AsyncPostBackTimeout="999999">
        <Services>
            <asp:ServiceReference path="../Services/DocLookups.svc" />
        </Services>
    </asp:ScriptManager>

The client proxies are working -- i.e. I can make calls through them, but I'm getting no Intellisense.

My service is defined with a .svc file:

<%@ ServiceHost Language="C#" Debug="true" Service="Documents.Services.DocLookups" CodeBehind="~/App_Code/DocLookups.cs" %>

The code behind file looks like:

[ServiceContract(Namespace = "Documents.Services", Name = "DocLookups")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class DocLookups {
...

a sample method in this class is:

    //Called at the begining of the page to fill in the category list
    [OperationContract]
    public SelectOption[] GetCategoriesForSelectList()
    {
        SelectOption[] Result;
        IDocumentRepository repository = new DocumentEntityRepository(ConnectionString);
        Result = (from cat in repository.GetDocCategories()
                  select new SelectOption(cat.Category_ID.ToString(), cat.CategoryName)).ToArray();
        if (Result.Length > 0)
            Result[0].Selected = true;  //Select first item 
        return Result;
    }

and it uses a data contract defined like this:

namespace Documents.Services {

[DataContract]
public class SelectOption
{
    //A useful DTO to use when filling a <select> element with options
    public SelectOption(string optionValue, string optionText) {
        OptionValue = optionValue;
        OptionText = optionText;
        Selected = false;
    }
    public SelectOption(string optionValue, string optionText, bool selected) {
        OptionValue = optionValue;
        OptionText = optionText;
        Selected = selected;
    }

    [DataMember]
    public string OptionValue { get; set; }
    [DataMember]
    public string OptionText { get; set; }
    [DataMember]
    public bool Selected { get; set; }
}

}

In my javascript files, a call to this service looks like:

Documents.Services.DocLookups.GetCategoriesForSelectList(...

but I get no Intellisense (for example, if I type Documents. nothing pops up). I don't get intellisense for either the generated methods or the [DataContract] types used by the methods.

I believe that I am supposed to get Intellisense for these proxies and types, but can't figure out what I might be doing wrong. TIA.

+3  A: 

Did /// <reference path="../Services/DocLookups.svc" /> not work?

Scott Hanselman
It didn't work initially, as I indicated in my post, but it DID work once I realized I had to preceed it with a ref to MicrosoftAjax.js/// <reference name="MicrosoftAjax.js" />/// <reference path="../Documents/Services/DocLookups.svc" />So thanks for the help.
Decker
A: 

Thanks to Scott for pointing out that I need to add the

///<reference path...

line. I don't know where it's documented but I somehow missed that this was required for the WCF generated client-side proxies -- although it makes sense now given the same idiom is used to get the Intellisense for JQuery.

For the record, the line I ended up having to use was slightly different than what Scott suggested given my projects structure. I tried:

/// <reference path="../Documents/Services/DocLookups.svc" />

I then saved the file and from the VS Edit menu chose Intellisense... Update JScript Intellisense...

Unfortunately, this did not work and I got the following error when updating the Intellisense:

Error updating JScript IntelliSense: 
C:\TFSSource\LitigationPortal\Version 1.0\LitigationPortal\Documents\Services\DocLookups.svc:
'Type' is undefined @ 0:0

So I've made some progress but I'm not quite there yet.

Decker
A: 

I came across this same problem and found that there's a hotfix for Visual Studio 2008 available that solved my issue:

http://support.microsoft.com/kb/958502

Adam Douglass