Visual Studio Orcas JavaScript IntelliSense
Bertrand has a great post about JavaScript IntelliSense with the next Visual Studio .NET code-name Orcas. I downloaded the bits to give it a try. Oh yes, it is working great when creating ASP.NET AJAX Web applications.
What about Web developers not using ScriptManager?
Hm, next I tried to run my AjaxPro library and add some JavaScript IntelliSense for next Visual Studio .NET. I tried several ways to include the on-the-fly generated JavaScript files, but I couldn't find any that would work. Only generating of theses files and including them as static JavaScript files was working.
I contacted Bertrand and the ASP.NET team to find a solution, but there is no real way to add generated JavaScript files during development.
The way JavaScript IntelliSense is working is to include eithere a <reference/> tag in the top of static JavaScript files or include them with the ScriptManager. But how can I include JavaScript files with the ScriptManager object if I don't want to use the automatic added ASP.NET AJAX JavaScript core scripts? Currently there is no way to disable core ASP.NET AJAX scripts. I'm still in hope that they will add this simple property to the ScriptManager, but Bertrand already told me that it is very late to be included in Orcas.
One way to workaround this and use the ScriptManager without adding the core ASP.NET AJAX scripts could be this:
protected override void OnPreInit(EventArgs e) { form1.Controls.Remove(ScriptManager1); // add now all your JavaScript files again // this.ClientScript.RegisterClientScript(...); base.OnPreInit(e); }
This will enable JavaScript IntelliSense without using the ScriptManager.
Where do I see problems?
The main problem I see is with the JavaScript IntelliSense is that it will only work if running ASP.NET AJAX applications. But what about using this without? What is if you want to use any other popular JavaScript framework? Because JavaScript IntelliSense includes (<reference/> tag) are only working in static JavaScript files it is not easy possible to have IntelliSense available for other frameworks.
Maybe I didn't see all ways to include external files, but if I need to use the ASP.NET AJAX ScriptManager I cannot develop Web applications that are working on mobile devices because not all JavaScript inside the core script files are working on older Web browsers or i.e. Windows Mobile. If you have any idea or solution feel free to add a comment below.
3 Comments
Comments have been disabled for this content.
bleroy said
Michael, I think you're making a small mistake here: if you want to use another framework in Orcas, you will use a plain script tag and it will work perfectly. The problem we've been talking about is very different: it's the case where the script is being added *dynamically* from server code by a control. In this case, the page developer will need to add a script reference or a script tag manually to get IntelliSense in the page. One thing we haven't discussed is that it is good practice anyway to put the application JavaScript code in a separate file. In this case, you'll need a tag on top of the file in all cases.
interactive said
Hi Bertrand, yes, we talked about this, but how can you add a framework/control that will add scripts without using tag? What if you have a control that you are going to use that offers JavaScript support? Think about Assembly resources that could not be added as a static file? How could I use IntelliSense there. Sorry for my cutup, but I talked with some Web developers and they all have this problem. If I'm wrong please help me to understand how I can use it correct? I see only static files and the use of the ScriptManager.
Todd Anglin said
Michael- This is a great question. Did you ever get follow-up from Bertrand? Most advanced ASP.NET components have rich client-side APIs these days, but the JS files are also usually added to the page at runtime as Web Resources. Is there no good way to get design time IntelliSense on these files? Thanks~