views:

15

answers:

2

I have a very simple code snitppet that looks like this:

<asp:Label Text="$Name$" runat="server" AssociatedControlID="$txtName$" />
<asp:TextBox runat="server" ID="$txtName$" />
<br />

What I was hoping was that the $txtName$ would be changed in both places, but it doesn't, only the first instance is changed and I can't even tab over to the second instance.

Is there a work around to this?

+1  A: 

This should work and does for me.

Can you show the complete snippet file? Here is one that works, type and fieldName are replaced multiple times:

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&gt;
    <Header>
        <Title>Non-automatically implemented property</Title>
        <Author>Richard Cox</Author>
        <Shortcut>propf</Shortcut>
        <Description>Property with exlicit field</Description>
        <SnippetTypes>
            <SnippetType>Expansion</SnippetType>
        </SnippetTypes>
    </Header>
    <Snippet>
        <Declarations>
            <Literal>
                <ID>propName</ID>
                <ToolTip>Property Name</ToolTip>
                <Default>Name</Default>
            </Literal>
            <Literal>
                <ID>fieldName</ID>
                <ToolTip>Field Name</ToolTip>
                <Default>field</Default>
            </Literal>
            <Literal>
                <ID>type</ID>
                <ToolTip>Property type</ToolTip>
                <Default>string</Default>
            </Literal>
        </Declarations>
        <Code Language="csharp">
            <![CDATA[private $type$ $fieldName$;
    public $type$ $propName$ {
        get { return $fieldName$;}
        set { $fieldName$ = value;}
    }

    $end$]]>
        </Code>
    </Snippet>
</CodeSnippet>
Richard
A: 

It turns out that the replacement was working, but not as I typed. So I can type what I need and then to get the additional properties changed I have to take the focus away from the snippet, so pressing the down arrow key does the job.

ilivewithian
Pressing `ENTER` is the normal way to do this, it completes the process of inserting the snippet.
Richard