ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)

Your Ad Here

ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)

This is the sixth in a series of blog posts I’m doing on the upcoming VS 2010 and .NET 4 release.

Today’s post covers another useful improvement in VS 2010 – HTML/ASP.NET/JavaScript snippet support. Snippets allow you to be more productive within source view by allowing you to create chunks of code and markup that you can quickly apply and use in your application with a minimum of character typing.

Visual Studio has supported the concept of “snippets” for VB and C# in previous releases – but not for HTML, ASP.NET markup and JavaScript. With VS 2010 we now support snippets for these content types as well.

Using ASP.NET Snippets

Let’s walkthrough how we can use snippets to quickly implement a common security scenario. Specifically, we’ll implement the functionality necessary to display either a “[ Login ]” link or a “[ Welcome UserName ]” message at the the top right of a site depending on whether or not the user is logged in:

step1

The above functionality is automatically added for you when you create a project using the new ASP.NET Project Starter Template in VS 2010. For the purpose of this walkthrough, though, we’ll assume we are starting with a blank master page and will build it entirely from scratch.

We’ll start by adding a standard

element to a master page, and then position our cursor within it:

step2

We are going to use the built-in control to help implement our scenario. The control is a templated control (first introduced with ASP.NET 2.0) that allows us to easily switch between “Anonymous” and “LoggedIn” templates that automatically display depending on whether the user is authenticated. Rather than type the markup manually, we’ll instead use the new snippet support in VS 2010.

Typing in “

step3

We’ll select the built-in “loginview” code snippet from the above list and hit the “tab” key to complete it:

Want to read full article, Go to Scott Blog

Happy Reading



Subscribe
Posted in Labels: , kick it on DotNetKicks.com |

7 comments:

  1. Anonymous Says:

    After I originally left a comment I appear to have clicked the -Notify
    me when new comments are added- checkbox and from now on every time
    a comment is added I receive four emails with the same comment.
    Is there a means you can remove me from that
    service? Many thanks!

    my blog :: Diarrhea Remedies

  2. Anonymous Says:

    Thank you for the auspicious writeup. It in fact was a amusement account it.
    Look advanced to far added agreeable from you!
    By the way, how could we communicate?

    Feel free to visit my webpage ... Recycling Facts

  3. Anonymous Says:

    At this moment I am going to do my breakfast, later than
    having my breakfast coming again to read more news.


    my weblog permanent hair straightening

  4. Anonymous Says:

    I loved as much as you will receive carried out right here.
    The sketch is tasteful, your authored material stylish.

    nonetheless, you command get got an nervousness over that you wish be delivering the following.

    unwell unquestionably come more formerly again since exactly
    the same nearly very often inside case you shield this
    increase.

    Stop by my web page; The interlace

  5. Anonymous Says:

    I could not refrain from commenting. Exceptionally well written!


    Also visit my blog - World Of Tanks Hack

  6. Anonymous Says:

    My brother recommended I might like this blog.
    He was totally right. This post actually made my day.
    You can not imagine just how much time I had spent
    for this information! Thanks!

    my web-site ... Install 7Zip

  7. Anonymous Says:

    Good respond in return of this difficulty with firm arguments and telling everything regarding that.


    Here is my homepage - Minecraft Crack