views:

97

answers:

1

I created a custom HTML code snippet in Visual Studio 2010 to insert a form field with label, textbox and RequiredFieldValidator. I specified Declaration tags for the control IDs, label text and validator ErrorMessage property. The snippet has been imported into the My HTML Snippets folder with the Code Snippet Manager in VS 2010.

When I insert the snippet, all the declarations are highlighted as expected and I can tab between them. However, as soon as I start typing in a value for any of the declarations, the declarations are no longer highlighted and the tab key does not take me to the next declaration.

Obviously it makes the snippet a lot less useful. Could anyone tell me what I've done wrong? Below is the source of my snippet:

<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&gt;
<CodeSnippet Format="1.1.0">
    <Header>
        <Title>textfield</Title>
        <Author>SS</Author>
        <Description>Creates a form field with a label and a textbox</Description>
        <Shortcut>textfield</Shortcut>
        <SnippetTypes>
            <SnippetType>Expansion</SnippetType>
        </SnippetTypes>
    </Header>
    <Snippet>
        <Declarations>
            <Literal>
                <ID>LabelControlID</ID>
                <ToolTip>The stem of the ID to use for the label control</ToolTip>
                <Default>lblMyField</Default>
            </Literal>
            <Literal>
                <ID>LabelText</ID>
                <ToolTip>The label for the field</ToolTip>
                <Default>My field</Default>
            </Literal>
            <Literal>
                <ID>InputControlID</ID>
                <Default>txtMyField</Default>
            </Literal>
            <Literal>
                <ID>ValidatorControlID</ID>
                <Default>rfvMyField</Default>
            </Literal>
            <Literal>
                <ID>RequiredFieldEmptyMessage</ID>
                <ToolTip>Enter a message to show in the RequiredFieldValidator</ToolTip>
                <Default>is required</Default>
            </Literal>
        </Declarations>
        <Code Language="html">
            <![CDATA[
                <tr>
                    <th><asp:Label ID="$LabelControlID$" runat="server">$LabelText$</asp:Label></th>
                    <td>
                        <asp:TextBox ID="$InputControlID$" runat="server" />
                        <asp:RequiredFieldValidator ID="$ValidatorControlID$" ControlToValidate="$InputControlID$" 
                            Display="Dynamic" ErrorMessage="*" EnableClientScript="true" 
                            Text="$RequiredFieldEmptyMessage$" runat="server"/>
                    </td>
                </tr>
            $end$]]>
        </Code>
    </Snippet>
</CodeSnippet>

A: 

I am having the exact same issue. My code looks very similar to Inertiaboogie

Please help, not being able to use the snippet is wasting a lot of time.

Thanks

Connor Ross