my6solutions

asp .net, the social web & other distractions

 

Running Apps

Disclaimer

I am in no way affiliated with Microsoft or Google. I am just another developer trying to make a difference. All opinions and observations are usually my own.

How to get Javascript and XML intellisense working under Visual Studio 2008 when creating an OpenSocial gadget XML file

Currently, I have only been partially successful. It's either you have javascript intellisense or XML intellisense but not both at once. Hopefully, someone who reads this might be able to enlighten us while I continue to look for the answer. But anyways the following should also work with Visual Web Developer.

1. To enable XML intellisense

You will need to place the extended OpenSocial 0.8 gadget spec XSD schema into C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas with all the other bunch of intellisense enabling XML schemas. Change the line

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

to

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

    targetNamespace="http://www.opensocial.org"

    xmlns="http://www.opensocial.org"

    elementFormDefault="qualified">

You can choose the value of the namespace you want to use arbitrarily. Lastly, ensure that this same namespace is used in your gadget, eg.

<Module xmlns="http://www.opensocial.org">

 

2. To enable javascript intellisense

The html and javascript code for your gadget is encapsulated by the CDATA 'tag' to prevent XML parser errors when parsing html and javascript code. Unfortunately, it also has the side effect of causing intellisense to not work very well at all.

To overcome this problem, in Visual Studio 2008, go to Tools -> Options -> Text Editor -> File Extension, enter 'xml' as the extension and choose 'User Control Editor' as the editor behaviour when handling .xml files. Now you should have javascript intellisense. If you want to have jquery intellisense, simply add 

 

<script src="../../Scripts/jquery-1.3.2.min.js" type="text/javascript" ></script>

to the CDATA section. And now you can use jquery to handle your gadget's javascript.

But you will probably now notice that the XML intellisense no longer works and warnings are popping out. This can be safely ignored.

Meanwhile, I will try to find a nicer solution to this.

 

 

 

Bookmark and Share

Permalink | Comments (0) | Post RSSRSS comment feed