You are not Logged in
Would you like to Login or Register

Today is: Friday, 05 September, 2008
Check this months hot topics

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#

<?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>
kick it on DotNetKicks.com del.icio.us digg Mister Wong YahooMyWeb Reddit Furl Spurl blogmarks

Related Downloads

  • evt Code Snippet
    Code snippet for 'protected void MethodName(object sender, EventArgs e)' method
Paul Hayman Skype
Author : Paul Hayman
Published : Wednesday, 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.

Add Comment

Enter your comment below and it will be submitted for moderation.

Your Name

Add Tag

Please enter tags for this article, seperated by semi-colon ;

View Tag's by : # articles | # views

Downloads

  • evt Code Snippet
    Code snippet for 'protected void MethodName(object sender, EventArgs e)' method