learning webmatrix part 3 of 3 akber alwani
TRANSCRIPT
Part 1What is WebMatrix?Razor SyntaxDatabase AccessWebGrid
Part 2LayoutsHelpers
Themes, Package Manager, Facebook and more
MembershipRouting
Part 3Building HelpersWebMatrix and OSS Web AppsPublishing your website or web appHow to “grow up” to Visual Studio 2010 and ASP.NET MVC
Agenda
1. Helpers make you more productive
Create Helpers for code that is repetitiveCreate 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 CSHTMLSave in App_Code folderThe name of the file is important – it’s used as the class name:
Building Helpers – inline syntax
@FacebookSocialPlugins.ShowLoginButton(...);
@helperEasy to create HTML shortcutsWrap commonly used HTMLTakes parametersReal 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> }
@functionReturn values from your helpersGood for wrapping complex APIs See the Twitter Helper for examples
Building Helpers – inline syntax
@functions {public static string SayHello(string name) {
return “Hello ” + name;}
}
Free & PopularLarge developer ecosystems with lots of widgets, plugins, templates and themesGood community support through blogs and forums
Gets you closer to a solutionCMS, 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
It’s easy to find a host that fits your needs and budgetPublishing your website is easy and pain freeFaster and more secureIf you make changes, you only upload the changes – not the entire website
Publishing your website
Find the right host for youQuickly compare the best dealswww.microsoft.com/web/hosting
Windows Web Hosting Gallery
Easy to configure, preview and publish your website and database in one click
Publishing in WebMatrix
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 App
Visual Studio 2010 provides the best solution to your “growing” needs:
Powerful editing capabilitiesTesting FrameworksSource/Version Control
Moving to Visual Studio 2010 is easyThe Razor Syntax is common across WebMatrix and ASP.NET MVC 3You can use Helpers in ASP.NET MVC 3Migration of database to IIS Express is easy to do
Growing Your App
Part 1What is WebMatrix?Razor SyntaxDatabase AccessWebGrid
Part 2LayoutsHelpers
Themes, Package Manager, Facebook and more
MembershipRouting
Part 3Building HelpersWebMatrix and OSS Web AppsPublishing your website or web appHow to “grow up” to Visual Studio 2010 and ASP.NET MVCRoadmap
Recap