Web matrix part 2


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • 1 minuteThis session is broken down into three parts, each of approximately 50-60 minutes. At the end of this training you will have a good base understanding of WebMatrix and how to build websites and web applications using the tool and framework.In Part 1 you will learn what WebMatrix is, who the intended users are for WebMatrix and what the Razor Syntax is. You will also learn how to access a database and how to use a WebGrid control to present its data in table format.In Part 2 you will learn how to use Layouts to maintain a consistent look and feel across all of the pages within your website. You will also be introduced to the use of helpers to manage different themes in your site, connecting to Facebook and more. Then you will learn about security and websites membership. Finally you will explore how the URL routing works in WebMatrix.In Part 3 you will discover how to create your own helpers to reuse your components in WebMatrix and we will discuss about WebMatrix and Open Source Software Web Applications integration. You will then learn how to publish your web applications. We will also discuss about when and how to move to Visual Studio and ASP.NET MVC application development.
  • 1 minuteWebMatrix comes with everything you need to get started building websites and web applications:A complete and integrated development environment, with a small download and a simple install. You get a database engine (SQL Server Compact Edition) to handle your data. All the structures you create in this database engine will be compatible with professional versions of SQL Server.WebMatrix supports a Web Server (IIS Express) to serve all your web pages. This web server is compatible with the professional versions of IIS as well.WebMatrix also comes with a new, simple programming framework that allows for rapid development of web sites and web applications. It supports Razor, the latest and simplifiedway to code web sites. It also provides a gallery of free open source applications to complement your development.It comes with an integrated installer that manages the heavy lifting of downloading and installing each component.
  • 3 minutesWhen we look at all the different profiles of people creating websites we see certain patterns emerge.First, there’s a group of people that like to use the large number of rich web applications out there as a starting point, and then add some specific functionality. They need a quick and easy way to customize and publish their solutions. Many of these web applications are tailored for specific tasks like Content Management Systems or eCommerce websites. These developers will often repeat this process many times for each customer, their goal is to make the process of acquiring the application, customization and publishing it as quick as possible.A second group need to create web apps from scratch. These developers are hobbyists, beginners and people who need a tool that is easy to learn and that allows them to focus on the application functionality instead of developers’ details.Finally, the group of professional developers. They need a powerful tool, full of features and able to work in team, perhaps distributed ones. They will use a source and version control and will need a testing framework to write their own unit tests. This tool needs to support the addition of 3rd party powerful extensions.WebMatrix is built for those developers that like to start from scratch or by building from a 3rd party web applications.
  • 10 minutesSee demo script for overview
  • 1 minuteWhen you create a new website from scratch in WebMatrix, you will be using the new Razor syntax. It’s very compact and easy to read and write, and allows you to flow between code and markup seamlessly. You can write your code in languages such as C# or VB, and it’s extensible via Helpers (we’ll talk about Helpers in Part 3)
  • 2 minutesWe’ve designed Razor to be concise and easy to use. When we think about the way developers use a language we take into account the context switching they have to do and also the number of keystrokes. The way that Razor allows you to transition seamlessly between markup and code makes for a much more natural and fluent style and also helps to reduce the number of keystrokes and context switching that a developer has to do, thinking about markup and code separately. With Razor, markup and code are really the same thing.We think it’s the easiest way to code websites and when you compare it to the other languages out there, it’s easy to see why.
  • 1 minuteThe transition from code to markup is one of the most elegant things about Razor but there a few rules that are worth knowing about. Option 1:Code is the primary citizen in a code block, not HTML. This means the parser will always expect code unless it finds valid opening (and closing) tags. In the first option block you see that after the @{ a name variable is defined. No additional tag is necessary. A <div> section tells Razor that what follows should be taken as literal. Then the @name indicates a variable that needs to be replaced with its value.Option 2:Similarly, to explicitly call out text in a code block as HTML, wrap it in a <text> tagOption 3:Single line of output within markup can be denoted by @:This option is useful when you don’t want to render an HTML element as part of the output. Extra Knowledge (Advanced):The Parser that understands Razor is itself a standalone assembly (System.Web.Razor.dll) which has no dependencies on ASP.NET which means you can use it to parse CSHTML/VBHTML files and produce C#/VB code in any .NET application.
  • 1 minuteIt’s always good practice to comment your code. In Razor we have the following options for commenting:Option 1:You can comment a block by using @* … *@Please note that this method could not be recursive (you could not have a @* inside another @*)Option 2:You can comment lines by using // (in C#) the same way you do in your code files.Option 3:If you need to comment a whole razor block, you should add a @* before the beginning of the code block and a *@ after it’s finish.
  • 5 minutesSyntax moving from code to markupObjectInfo()ServerInfo()
  • 2 minutesThe database that comes with WebMatrix is SQL Compact Edition, or SQL CE for short.It’s free, lightweight and doesn’t require a separate server to run – which makes it much easier to get setup and running than traditional versions of SQL Server like SQL Server Express.SQL Compact Edition includes tools to manage your tables and data and because it’s file-based, you simply need to copy the database files to transport your database to another machine. This is really useful if you are sharing a database with another developer.This sample code shows how to connect to an ArtGallery Database and then perform a query with SQL to retrieve the ArtGallery products.
  • 5 minutesCreating DBDesigning DBAccessing DB using Razor(introduce URLData)
  • 2 minutesAs we’ve seen, the database design and access from Razor code in WebMatrix is easy. Often when we’re building websites, we’ll want to render data in some form of table. The WebGrid can help to make this easy to do. Build 1In it’s simplest form, just give the WebGrid data and it will render it out in a valid HTML table. WebMatrix will make all the magic for you. But this has a few drawbacks: You’re not choosing the columns you want to show and they will be named as the field names in the database.Build 2 In the second sample, you explicitly state which columns to include in the WebGrid, their title (e.g.: «Product» instead of «Name») and how they will be formatted: Product column will use a CSS style, Description will appear in italic font, and so on.Build 3In the last sample, you can see that we order the data by the «Name» column and by simply defining one parameter, we state that we want 3 rows per page. WebMatrix will do the rest for you.
  • Any Queries
  • Thanking You
  • Web matrix part 2

    1. 1. Microsoft Student Partner Program @<br />Anna University of Technology <br />Coimbatore<br />
    2. 2. WebMatrix: Part 2<br />by<br />N.Yuvaraj<br />Yuvaraj.N@msptechrep.com<br />
    3. 3. Agenda<br />Overview<br />Introducing WebMatrix<br />Putting things into perspective<br />Who is WebMatrix for?<br />Who is Web Matrix intended for?<br />Typical Usage Scenarios<br />What it actually consists of<br />The ASP.NET family<br />Web Matrix Project Feature Overview<br />Community / Code Sharing Features<br />Installation of webmatrix<br />WebPages<br />A lap around WebMatrix<br />
    4. 4. Agenda<br /><ul><li>Introducing Razor
    5. 5. Razor is a cut above the rest
    6. 6. Move from code to markup easily with Razor
    7. 7. Commenting in Razor
    8. 8. Razor syntax
    9. 9. Database
    10. 10. SQL CE + IIS Express
    11. 11. Database Access
    12. 12. Display your data easily with WebGrid
    13. 13. Web Matrix Project and Visual Studio .NET
    14. 14. Key Feature Side by Side Comparison</li></li></ul><li>Overview<br />Customer Promise: <br />WebMatrix makes it easy for anyone <br />to create a new web site, customize it<br /> and publish it on the internet<br />Create<br />Customize<br />Publish<br />Easy to get started –begin with an open source app, a template, or begin coding from scratch<br />Support commonly used web files, features such as color coding, support for programming syntax ‘Razor’, single line-of-code solutions for complex coding tasks and SEO <br />If you already have a site, you can upload your files using FTP, FTPs or WebDeploy. If you don’t have a hosting provider, WebMatrix can recommend one<br />
    15. 15. Introducing WebMatrix<br />Web Server<br />Database<br />Development Tool<br />
    16. 16. Introducing WebMatrix<br />The Microsoft ASP.NET Web Matrix Project is a lightweight, easy to use, community-oriented tool for developing Web applications with ASP.NET<br />
    17. 17. Putting things into perspective<br />Task focussed tool to make it really easy to get started with web development<br />
    18. 18. Who is WebMatrix for?<br />I’m a professional software developer and I build complex, large scale web sites with a team of developers<br />I want to build web sites myself with an easy to learn tool and framework<br />I <3 Web Apps. I just need a tool that makes them easier to configure, customize and publish them<br />WebMatrix<br />WebMatrix<br />Visual Studio 2010<br />
    19. 19. Who is Web Matrix intended for? <br />Hobbyist / Student developers<br />Learn ASP.NET<br />Build simple sites<br />Work independently <br />Want to get connected to ASP.NET community<br />Developers who wish to try out ASP.NET<br />Zero-cost opportunity<br />Discover the technology and the active community<br />
    20. 20. Typical Usage Scenarios<br />Hobbyist Web developer <br />Personal / family / community site<br />Photo album, sports team, community picnic etc.<br />Web developers currently using other technologies:<br />Investigate / evaluate ASP.NET at zero cost<br />New developer / Student <br />Learn about ASP.NET for work / school project <br />Current ASP developer <br />Migrate simple ASP site to ASP.NET<br />Migrate skills to ASP.NET<br />
    21. 21. What it actually consists of<br />Templates<br />Web App Gallery<br />Programming Framework: ASP.NET/PHP<br />Web Server: IIS Express<br />Database: SQL Server Compact/MySQL<br />
    22. 22. The ASP.NET family<br />ASP.NET<br />Dynamic Data <br />& AJAX<br />Presentation<br />ASP.NET<br />WebForms<br />ASP.NET<br />WebPages<br />ASP.NET<br />MVC<br />ASP.NET<br />Core<br />Core <br />Runtime<br />
    23. 23. Web Matrix Project Feature Overview<br />Simple / Easy to use<br />File based workspace (no projects)<br />WYSIWYG Web Form Designer<br />Integrated Data Designers<br />Task based tools and wizards<br />FTP hosting support<br />Code Builders (code-generating wizards)<br />Code Snippet Sharing<br />
    24. 24. Web Matrix Project Feature Overview<br />Lightweight<br />Small footprint (~1MB + .NET Framework Redist) / fast download<br />No project system (entirely file based)<br />Self contained web server for testing (does not serve pages externally)<br />Community Oriented<br />Control / Add-in / Code builder Gallery Pickers<br />Instant Messaging Client Integration (Web Matrix buddies)<br />Integrated Chat Client<br />Community Tab with links to community<br />
    25. 25. Community / Code Sharing Features<br />Snippets<br />Import / Export<br />Controls gallery integration<br />Download controls from the Web<br />Community tab<br />Collection of resources<br />MSN Messenger integration <br />Web Matrix buddy list<br />Community search<br />Search community listservs<br />MSDN integrated class browser<br />
    26. 26. Web PI<br />
    27. 27. Package installs<br />
    28. 28. Quick installation process<br />
    29. 29.
    30. 30. Local application<br />
    31. 31. Start screen<br />
    32. 32.
    33. 33.
    34. 34. WebPages<br />Convention<br /> Backend logic on top<br /> Frontend logic below (html5 + code)<br />Simpler to use, but still ASP.NET power<br />
    35. 35. A lap around WebMatrix<br />Demonstration<br />
    36. 36. Introducing Razor<br />The easiest way to code websites<br />Easy to mix HTML and Code<br />Lots of useful Helpers<br />
    37. 37. Razor is a cut above the rest<br />Web Forms (6 markup transitions):<br /><ul><br /><% for (int i = 0; i < 10; i++) { %><br /> <li><% =i %></li><br /><% } %><br /></ul><br /><ul><br /><?php<br />for ($i = 0; $i < 10; $i++) {<br />echo("<li>$i</li>");<br /> } <br /> ?><br /></ul><br />PHP(2 markup transitions & an echo):<br /><ul><br />@for (int i = 0; i < 10; i++) {<br /> <li>@i</li><br /> }<br /></ul><br />Razor (2 markup transitions):<br />
    38. 38. Move from code to markup easily with Razor<br />@{<br />var name = “John Doe”;<br /> <div><br /> Your name: @name<br /> </div><br />}<br />Option 1:<br />HTML Block<br />@{<br />var name = “John Doe”;<br /> <text><br /> Your name: @name<br /> </text><br />}<br />Option 2:<br />Text Block<br />@{<br />var name = “John Doe”;<br /> @: Your name: @name<br />}<br />Option 3:<br />Single line of output<br />in markup<br />
    39. 39. Commenting in Razor<br />@*<br /> <div><br /> Hello World<br /> </div><br />*@<br />Option 1:<br />Markup<br />@{ <br /> //var name = "John Doe”;<br /> //@name<br />}<br />Option 2:<br />Code<br />@*<br /> @{ <br />var name = "John Doe";<br /> @name<br /> }<br />*@<br />Option 3:<br />Both<br />
    40. 40. Razor syntax<br />Demonstration<br />
    41. 41. Database<br />SQL Compact Edition<br />File-based, so it’s portable. Runs without a server.<br />Easy to design, easy to code against<br />Designing<br />Coding<br />@{<br />vardb = Database.Open("ArtGallery");<br />var product = db.Query("SELECT * FROM PRODUCTS); <br />}<br />
    42. 42. SQL CE + IIS Express<br />SQL CE:<br />File based (*.sdf)<br />Runs in medium trust -> hosting!<br />Put in App_Data folder<br />IIS Express:<br />No admin needed<br />IIS capabilities + Cassini ease of use combined<br />
    43. 43. Database Access<br />Demonstration<br />
    44. 44. Display your data easily with WebGrid<br />Displays your data quickly and easily<br />Lots of options to customize layout, appearance, paging etc.<br />@{<br />vardb = Database.Open("ArtGallery");<br />var data = db.Query("SELECT * FROM PRODUCTS);<br />var grid = new WebGrid(data);<br />}<br /><div id="grid"><br />@grid.GetHtml();<br /></div><br /><div id="grid"><br /> @grid.GetHtml(<br />columns: grid.Columns(<br />grid.Column("Name", "Product", style: "product"),<br />grid.Column("Description", format:@<i>@item.Description</i>),<br />grid.Column("Price", format:@<text>$@item.Price</text>)<br /> )<br /> )<br /></div><br />@{<br />vardb = Database.Open("ArtGallery");<br />var data = db.Query("SELECT * FROM PRODUCTS);<br />var grid = new WebGrid(<br /> source: data,<br />defaultSort: "Name",<br />rowsPerPage: 3);<br />}<br />
    45. 45. Web Matrix Project and Visual Studio .NET <br />Complementary tools<br />Web Matrix Project<br />Targets needs of hobbyist Web developer<br />Focused on Web application development <br />Built for community interaction<br />File-based projects<br />No support for<br />Team-based development<br />IntelliSense<br />Debugging<br />Visual Studio .NET<br />Target the needs of professional developers<br />Features for the enterprise developer <br />Team and collaboration-oriented <br />Architect features<br />Wide range of project types<br />Web applications to desktop<br />Rich client applications to device applications <br />
    46. 46. Key Feature Side by Side Comparison<br />
    47. 47. Any Queries<br />
    48. 48. Thanking You<br />