I have been banging my head against this for a little while now. I just can't seem to get intellisense to work in a ascx user control, but it works fine in a plain old aspx.
Here is a sample aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestScriptLoader._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="scriptManager" ScriptMode="Debug" runat="server" >
<Scripts>
<asp:ScriptReference Path="http://ajax.microsoft.com/ajax/beta/0910/Start.js" ScriptMode="Inherit" />
</Scripts>
</asp:ScriptManager>
</form>
<script type="text/javascript">
</script>
</body>
</html>
I get intellisense for MicrosoftAjax in the script tag there, once I've updated javascript intellisense (CTR+SHIFT+J).
In the ascx file
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test.ascx.cs" Inherits="TestScriptLoader.Test" %>
<asp:ScriptManagerProxy ID="scriptManagerProxy" runat="server">
<Scripts>
<asp:ScriptReference Path="http://ajax.microsoft.com/ajax/beta/0910/Start.js" ScriptMode="Inherit" />
</Scripts>
</asp:ScriptManagerProxy>
<script type="text/javascript">
</script>
I get no such joy.
The only thing I can think of is to do all the coding for the user controls in a seperate JS file, but there is a one to one mapping for the functionality that I want in specific usercontrols to the javascript I will write for them, and the user control will only appear once in a page. Basically I don't want to go down this path if not absolutely neccesary.
EDIT
I also need to be able to add service references to these controls, and have intellisense available.
EDIT
It just struck me that the problem I'm up against is that I'm using a scriptmanagerproxy inside a usercontrol. The usercontrol has no way of knowing which ScriptManager it is to associate with, so that is why the javascript intellisense is not being updated.
I can verify this by changing the scriptmanagerproxy to a scriptmanager control, and intellisense works for both the script and service references.
EDIT
I also thought I could just stick an <asp:ScriptManager>
into the page, wrapped in alligator clips:
<% if(false) { %>
<asp:ScriptManager ID="fakeScriptManager" runat="server"/>
<% } %>
<asp:ScriptManagerProxy ID="scriptManagerProxy" runat="server">
<Services>
<asp:ServiceReference Path="~/path/to/your.svc" />
</Services>
</asp:ScriptManagerProxy>
That appeared to work, but the <% if(false) %>
does not prevent the control from being built...
Any ideas on how to get this to happen?