LCJ
LCJ

Reputation: 22652

How to use HTML Code Snippet?

I am trying to create and use code snippets using Visual Studio 2005. I successfully created a snippet in VB.Net and used it by typing it’s shortcut and pressing tab. Now I am trying to use a html snippet.

I have built in code snippets present in following location

“C:\Program Files (x86)\Microsoft Visual Studio 8\Xml\1033\Snippets\xslt\html”.

It’s shortcut is “htmltable”. But when I press “tab” after typing “htmltable”, nothing is happening. [Even tried tab twice].

Any idea what I could be missing here?

REFERENCES

  1. Walkthrough: Using HTML Snippets
  2. Code Snippet Picker
  3. Walkthrough: Creating a Code Snippet
  4. How to: Manage Code Snippets

Upvotes: 1

Views: 1416

Answers (1)

LCJ
LCJ

Reputation: 22652

It worked in VS2013.

  1. Press Ctrl+K and Ctrl+B to launch Code Snippet Manager
  2. Add the Custom Snippet in the folder "My HTML Snippets" [It can be seen that the file is copied to “C:\Users\\Documents\Visual Studio 2013\Code Snippets\Visual Web Developer\My HTML Snippets” also.]

Following is the snippet I used:

<CodeSnippet Format="1.1.0"
    xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <!--DataGrid -->
  <Header>
    <Title>MyDataGrid</Title>
    <Author>Lijo</Author>
    <Shortcut>MyDataGrid</Shortcut>
    <Description>Markup snippet for a MyDataGrid</Description>
    <SnippetTypes>
      <SnippetType>Expansion</SnippetType>
    </SnippetTypes>
  </Header>
  <Snippet>
    <Declarations>
      <Literal>
        <ID>MyDataGrid</ID>
        <ToolTip>MyDataGrid</ToolTip>
        <Default>MyDataGrid</Default>
      </Literal>
    </Declarations>
    <Code Language="html">
      <![CDATA[

      <ANET:DataGrid runat="Server" ID="dgMultiTextile" AlternatingItemStyle-BackColor="#dddddd"
        ItemStyle-HorizontalAlign="center" Width="100%">
        <Columns>
          <ANET:BoundColumn DataField="IncomingTransCD" LabelName="InTransCDText"/>
          <ANET:TemplateColumn LabelName="BusinessUnitText">
            <ItemTemplate>
              <a href="#" class="businessUnitHyperLink">
                <asp:label id="lnkBusinessUnitCD" name="BusinessUnitCD" runat="server" fieldname="BusinessUnitCD"
                    text='<%# Container.DataItem.Item("BusinessUnitCD") %>'></asp:label>
              </a>
            </ItemTemplate>
          </ANET:TemplateColumn>
        </Columns>
      </ANET:DataGrid>
      $end$]]>
    </Code>
  </Snippet>
</CodeSnippet>

REFERENCES:

  1. A useful presentaion from Jeff King Microsoft Visual Studio: Web Development Futures

Upvotes: 1

Related Questions