Tutorial :Creating a Custom DTD for Visual Studio



Question:

I've got some custom templated controls which take JavaScript as template content, like so:

<ns:Custom runat="server">      <contentTemplate>          var a = new Array();          for (var i=0; i<a.length; i++) {              // do something          }      </contentTemplate>  </ns:Custom>  

I want VisualStudio to treat the content of exactly the same as it does elements so that code coloring take effect and the validator doesn't puke on the "<" in the for-loop definition.

My understanding is that a custom DTD needs to be created to solve this. Does anybody know how to do this, have have links to resources for it?


Solution:1

I admit I'm not familiar with VS templated controls, but this looks like XML (given the "ns:" namespace), and the standard way to embed left angle brackets inside XML, without them being treated as tags, is with CDATA:

<ns:Custom runat="server">      <contentTemplate>          <![CDATA[          var a = new Array();          for (var i=0; i<a.length; i++) {              // do something          }          ]]>      </contentTemplate>  </ns:Custom>  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »