Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Web Developer

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « Writing a simple website with webmatrix, razor and VB.NetCatching Key Conflicts with Perl's Class::DBI »
    comments

    Introduction

    Last week I attended a webcamp with Scott Hanselman and he showed Webmatrix and how cool it really is. So today I had some time to try it out and make myself a cool website.

    Installation

    He said it was only 8MB to download. It is only 8MB to download untill you click the install button after which it starts downloading a whole lot more software. It probably is no problem for people with fast internet.

    YOu can download webmatrix from the ASP.Net webpages. YOu just have to click the big green button on the install page.

    That will download the webinstaller which is only 8MB.

    And then the downloading begins.

    It will install IIS-express and some other things it needs.
    This is a list of things it installed on my machine.

    First site

    So the installation was pretty painless. Now let's get me a site. I used a template and used starter site (seemed the most logical thing a novice would click).

    This is were you end up after you click ok.

    And this is what happens when you click run.

    That was simple and quick. Now let's see if I can do some razor things with it.

    Razor

    Just doing some quick and dirty things with it now. AS usual you have to jump through hoops to use VB as your language. YOu have to pick a vbhtml for this.

    It is not in common nor in suggested, you have to go to all.

    So I create a Page called Page and added it to the menu. You have to change _SiteLayout.cshtml for that. Like this.

    1. <ul id="menu">
    2.                     <li><a href="@Href("~/")">Home</a></li>
    3.                     <li><a href="@Href("~/Page")">Page</a></li>
    4.                     <li><a href="@Href("~/About")">About</a></li>
    5.                 </ul>

    When you make a new page as vbhtml you get all this.

    1. <!DOCTYPE html>
    2. <html lang="en">
    3.     <head>
    4.         <meta charset="utf-8" />
    5.         <title></title>
    6.     </head>
    7.     <body>
    8.        
    9.     </body>
    10. </html>

    Which we don't need. I want my page to look like the rest.

    Finding the right syntax is a bit tricky if you insist on doing VB.Net since most examples are in C#.

    But here it is.

    1. @Code
    2.     Layout = "~/_SiteLayout.cshtml"
    3.     Page.Title = "Welcome to my Web Site!"
    4. End Code
    5. <p>
    6.     ASP.NET Web Pages make it easy to build powerful .NET based applications for the web.
    7.    
    8. </p>

    That now looks the same as the default page.

    Next thing I wanted to find out is how to do a for loop.

    This is what it looks like.

    1. @Code
    2.     Layout = "~/_SiteLayout.cshtml"
    3.     Page.Title = "Welcome to my Web Site!"
    4. End Code
    5. <p>
    6.    ASP.NET Web Pages make it easy to build powerful .NET based applications for the web.
    7.    In VB.Net.
    8.     <ul>
    9.     @for i as integer = 1 to 10
    10.         @<li>@i</li>
    11.     next
    12.     </ul>    
    13. </p>

    And this the result.

    I was a bit surprised with the syntax, I don't think it is all that consistent (why no @ before the next? and why do I need the @ in front of the li?) but I could get used to it over time.

    Conclusion

    It was fun playing with it. It is very fast to install and a breeze to get it working (I can still remember the nightmares I used to have with eclipse and such). The easy of getting started is crucial to get people in to development. You don't want to scare people away just because they can't get it installed. But don't worry, people who are not willing to learn the syntax or learn anything about development will soon give up.

    About the Author

    User bio imageChris is awesome.
    Social SitingsTwitterHomePageLTD RSS Feed
    InstapaperVote on HN

    3 comments

    Comment from: Ted Krueger (onpnt) [Member]
    Ted Krueger (onpnt) >>But don't worry, people who are not willing to learn the syntax or learn anything about development will soon give up.

    Sometimes not soon enough and the damage they make it hard to recover from :(

    I'm going to check this out. Looks like what I need for a project I'm working on. Thanks, Chris!
    01/31/11 @ 06:25
    Comment from: Clacla [Visitor]
    Clacla thanks for the article! Useful to me. Will give it a try in VB.NET...
    02/18/11 @ 16:42
    Comment from: rick [Visitor]
    rick Wonder why Microsoft has seen fit to not include VB versions of the samples? Could it be that VB will be dropped in the future?

    Makes me miss Bill G. running MS.
    02/23/11 @ 12:04

    Leave a comment


    Your email address will not be revealed on this site.

    To mislead the spambots.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)