Code snippet for 'protected void MethodName(object sender, EventArgs e)' method
When adding a method to handle server events (such as OnClick) I often found myself copying the Page_Load method and changing the name. I looked for a snippet which would create this method for me but had no luck, so I wrote one.
The snippet shortcut
Type evt then hit <tab><tab>
What the snippet outputs
protected void YourMethodName(object sender, EventArgs e)
{
}
The Snippet
Save this snippet in your snippet folder as evt.snippet (see the download links for this article)
The snippet folder is typically located here:
\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Visual C#
or here:
\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>evt</Title>
<Shortcut>evt</Shortcut>
<Description>Code snippet for 'protected void MethodName(object sender, EventArgs e)' method</Description>
<Author>Paul Hayman</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>methodname</ID>
<ToolTip>Method Name</ToolTip>
<Default>Page_Load</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[protected void $methodname$(object sender, EventArgs e)
{
$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
| Author |
: Paul Hayman |
| Published |
: 02 August 2006 |
Paul is the COO of kwiboo ltd consultant and has more than a decade of IT consultancy experience. He has consulted for a number of blue chip companies and has been exposed to the folowing sectors: Utilities, Telecommunications, Insurance, Media, Investment Banking, Leisure, Legal, CRM, Pharmaceuticals, Interactive Gaming, Mobile Communications, Online Services.
Paul is the COO and co-founder of kwiboo (http://www.kwiboo.com/) and is also the creator of GeekZilla.