Learning WebMatrix Part 3 of 3

adhocjackpotΑσφάλεια

5 Νοε 2013 (πριν από 3 χρόνια και 7 μήνες)

111 εμφανίσεις

Learning WebMatrix

Part 3 of 3

Akber

Alwani

http://twitter.com/epdotnet

Part 1

What is WebMatrix?

Razor Syntax

Database Access

WebGrid

Part 2

Layouts

Helpers

Themes, Package Manager, Facebook and more

Membership

Routing

Part 3

Building Helpers

WebMatrix and OSS Web Apps

Publishing your website or web app

How to “grow up” to Visual Studio 2010 and ASP.NET MVC


Agenda

1. Helpers make you more productive

Create Helpers for code that is repetitive

Create Helpers for code that is complex

2. Helpers make it easier for other
developers to use your widgets or
services

Useful if you are trying to create a
developer ecosystem of your own


Why Build Helpers?

Build a Helper: The 3 Approaches


@helper syntax using CSHTML


For simple helpers

Use Inline Code


Static class with Static methods


For helpers that use .NET Framework

Use a Class (Intermediate)


Requires Visual Studio 2010 for development


For complex helpers that require testing

Use an assembly (DLL) (Advanced)

Use CSHTML

Save in
App_Code

folder

The name of the file is important


it’s
used as the class name:


Building Helpers


inline syntax



@
FacebookSocialPlugins.ShowLoginButton
(...);


@
helper

Easy to create HTML shortcuts

Wrap commonly used HTML

Takes parameters

Real example: Facebook Social Plugins






Building Helpers


inline syntax



@helper
HelloWorld
(string name = "") {


<div>Hello @name</div>


}




@helper
ShowLoginButton
(string
buttonText

= "") {


<
fb:login
-
button
>@
buttonText
</
fb:login
-
button
>


}


@function

Return values from your helpers

Good for wrapping complex APIs

See the Twitter Helper for examples


Building Helpers


inline syntax



@functions {


public static string
SayHello
(string name) {



return “Hello ” + name;


}


}


BUILDING HELPERS

Demonstration

Free & Popular

Large developer ecosystems with lots of
widgets, plugins, templates and themes

Good community support through blogs
and forums

Gets you closer to a solution

CMS,
eCommerce
, Forum etc.

Easy to configure



Why use Open Source Apps?

WebMatrix builds on the success of
the Web Platform Installer


2.5 Million Apps downloaded so far

WebMatrix and OSS Apps

Web Platform
Installer

WebMatrix

Download





Install

(
inc.

dependencies)





Customize



SEO Analysis



Publish



INSTALL A WEB APP

Demonstration

It’s easy to find a host that fits your
needs and budget

Publishing your website is easy and
pain free

Faster and more secure

If you make changes, you only upload
the changes


not the entire website



Publishing your website

Find the right host for you

Quickly compare the best deals

www.microsoft.com/web/hosting


Windows Web Hosting Gallery

Easy to configure, preview and publish
your website and database in one click

Publishing in WebMatrix

PUBLISHING YOUR WEBSITE

Demonstration

With a little luck, your web application will be
successful and attract lots of users!

1.
Congratulations


2.
You need to ask yourself some questions:


1.
Do I need more developers?

2.
Is my code base still manageable?

3.
Do I need to scale my web & database
servers?


With
a successful application the answer will
normally be “YES”
to those
questions



Growing Your
A
pp

Visual Studio 2010 provides the best
solution to your “growing” needs:

Powerful editing capabilities

Testing Frameworks

Source/Version Control

Moving to Visual Studio 2010 is easy

The Razor Syntax is common across
WebMatrix and ASP.NET MVC 3

You can use Helpers in ASP.NET MVC 3

Migration of database to IIS Express is easy
to do

Growing Your App

GROWING YOUR APP

Demonstration

Part 1

What is WebMatrix?

Razor Syntax

Database Access

WebGrid

Part 2

Layouts

Helpers

Themes, Package Manager, Facebook and more

Membership

Routing

Part 3

Building Helpers

WebMatrix and OSS Web Apps

Publishing your website or web app

How to “grow up” to Visual Studio 2010 and ASP.NET MVC

Roadmap

Recap

www.webcamps.ms

www.asp.net/webmatrix

www.microsoft.com/web/webmatrix

Get this content, and more

Join in the community!

Facebook Fan Page (search for Web Camps)

Follow @
Webcamps

on Twitter

You are a Web Camper!