Articles : Page 1 of 1

  • Using QUnit with Razor Layouts

    Using QUnit with Razor Layouts

    Dec 11
    11

    Given how central JavaScript is to many modern web applications,  it is important to use unit tests to drive the design and quality of that JavaScript. But I’ve noticed that there are a lot of developers that don’t know where to start. There are many test frameworks out there, but the one I love is QUnit, the jQuery unit test framework. Most of my experience with QUnit is writing tests for a client script library such as a jQuery plugin. Here’s an example of one QUnit test file I wrote a ...


  • A Simple 2-Column Layout in Razor

    A Simple 2-Column Layout in Razor

    Aug 11
    22

    2 column layouts are rather popular on the web, and there are 1,001 ways to make them work. The approach you choose really depends on the type of content you have, and how you want images and backgrounds to work. What I'll show is the Razor _Layout and CSS to achieve the following look: The Razor _Layout file can rely on partial views to handle each of the primary sections: top, navigation, sidebar, and footer. RenderBody will produce the primary content area. <!DOCTYPE html> <html> <hea...


  • ASP.NET MVC 3 and the @helper syntax within Razor

    ASP.NET MVC 3 and the @helper syntax within Razor

    May 11
    13

    ASP.NET MVC 3 supports a new view-engine option called “Razor” (in addition to continuing to support/enhance the existing .aspx view engine). Razor minimizes the number of characters and keystrokes required when writing a view template, and enables a fast, fluid coding workflow. Unlike most template syntaxes, with Razor you do not need to interrupt your coding to explicitly denote the start and end of server blocks within your HTML. The Razor parser is smart enough to infer this from your co...


  • Defining Default Content For A Razor Layout Section

    Defining Default Content For A Razor Layout Section

    Mar 11
    05

    Layouts in Razor serve the same purpose as Master Pages do in Web Forms. They allow you to specify a layout for your site and carve out some placeholder sections for your views to implement. For example, here’s a simple layout with a main body section and a footer section. <!DOCTYPE html> <html> <head><title>Sample Layout</head> <body> <div>@RenderBody()</div> <footer>@RenderSection("Footer")</footer> </body> </html> In order to use this layout, your view might look like. @{ Layout ...



  • 1