Get IntelliSense Support in HTML View - 25 Jul 2002
Get IntelliSense Support in HTML ViewImagine you have a custom control in the Visu
July 24, 2002
Get IntelliSense Support in HTML View
Imagine you have a custom control in the Visual Studio .NET toolbox. You select and drop it onto a Web form. You can now configure the control via the Properties window and write code to handle events in the page’s code-behind class. In doing so, you take full advantage of IntelliSense and get handy lists of methods, events, and values whenever you’re completing a statement.
It passes unnoticed to most developers that IntelliSense support is available not just in code-behind mode, but also in HTML view. However, custom controls require some extra efforts to work properly with the IntelliSense engine in the page’s HTML view.
In code-behind mode, IntelliSense uses .NET reflection to query for members to display; in HTML view mode, there’s no .NET object to query. In this case, IntelliSense learns about the programming interface of the control through an XML schema. The markup of standard controls is hard-coded in a system XSD file that ships with Visual Studio .NET. The markup of your controls must be created and deployed properly for IntelliSense to work as expected. Necessary steps are outlined as follows:
Create a XSD file describing your control
Copy this XSD file either in the root of the application or, to make it visible to all applications, copy it to C:Program FilesMicrosoft Visual Studio .NETCommon7Packagesschemasxml
Make sure the namespace of the XSD schema is correctly referenced in each page that uses the control
The XSD schema for the control has a standard layout and you can easily modify the one provided with this article to create a schema that fits your next control. The key thing is defining the namespace for the schema. In addition, you must define the custom properties of your control. The sample below works for a control that extends HyperLink by adding a Boolean property named AllowSiteCounter.
targetNamespace="http://schemas.microsoft.com/hyper"
xmlns="http://schemas.microsoft.com/hyper">
:
type="xsd:boolean"/>
You copy this file in the right folder (see above) and then link the schema namespace to the Web page you’re writing, as follows:
:
The control must be registered in the page with the same prefix of the namespace. In the download, you find a sample Web control and the full source code of the XSD schema.
Read more about:
MicrosoftAbout the Author
You May Also Like