通过将补丁 KB958502 应用于 Visual Studio 2008 并包括以下行,我终于让 Intellisense 为 JQuery 工作:
/// <reference path="JQuery\jquery-1.3.2.js"/>
在我的 .js 文件的顶部。现在我试图弄清楚如何为 ScriptManager 的 ScriptReference 元素生成的客户端代理获取 JavaScript 智能感知(如下所示):
<asp:ScriptManager ID="ScriptManager1" runat="Server" EnablePartialRendering="false" AsyncPostBackTimeout="999999">
<Services>
<asp:ServiceReference path="../Services/DocLookups.svc" />
</Services>
</asp:ScriptManager>
客户端代理正在工作——即我可以通过它们拨打电话,但我没有得到智能感知。
我的服务是用 .svc 文件定义的:
<%@ ServiceHost Language="C#" Debug="true" Service="Documents.Services.DocLookups" CodeBehind="~/App_Code/DocLookups.cs" %>
文件后面的代码如下所示:
[ServiceContract(Namespace = "Documents.Services", Name = "DocLookups")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class DocLookups {
...
此类中的示例方法是:
//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;
}
它使用如下定义的数据合约:
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; }
}
}
在我的 javascript 文件中,对该服务的调用如下所示:
Documents.Services.DocLookups.GetCategoriesForSelectList(...
但我没有得到 Intellisense(例如,如果我键入 Documents。没有弹出)。对于生成的方法或方法使用的 [DataContract] 类型,我都没有获得智能感知。
我相信我应该为这些代理和类型获得 Intellisense,但无法弄清楚我可能做错了什么。TIA。