WebMatrix Helpers

This post provides details and code syntax about the helpers provided in WebMatrix (Beta).

If you're not familiar with WebMatrix, here are a few details. WebMatrix is used to build Web sites. It includes IIS Developer Express (a development Web server), ASP.NET (a Web framework), and SQL Server Compact (an embedded database). It streamlines Web site development and makes it easy to start Web sites from popular open-source apps. WebMatrix helps to reduce the complexity of developing Web sites.

WebMatrix Helpers help you add common functionality to your Web site. Here's a table of common helpers. Note that the syntax included here includes ALL the members for each helper.

Helper

Description

Syntax

Analytics

Renders Analytics JavaScript code. Analytics is a general term for technology that measures traffic on your website so you can understand how people use the site. Many analytics services are available, including services from Google, Yahoo, StatCounter, and others. For more information, see Analyzing Traffic on Your Website.

Analytics.GetGoogleHtml(webPropertyId)

Analytics.GetStatCounterHtml(project, security)

Analytics.GetYahooHtml(account)

FaceBook

Lets Facebook users make a connection to pages. For more information see, Adding Social Networking to your Website.

Facebook.LikeButton(url, action, width, layout, showFaces, colorScheme)

FileUpload

Renders UI for uploading files. For more information, see Working with Files.

FileUpload.GetHtml(initialNumberOfFiles, allowMoreFilesToBeAdded, includeFormTag,

 addText, uploadText)

GamerCard

Renders the specified Xbox gamer tag. For more information see, Adding Social Networking to your Website.

GamerCard.GetHtml(gamerTag)

Gravatar

Renders the Gravatar image for the specified email address. A Gravatar (a “globally recognized avatar”) is an image that can be used on multiple websites as your avatar—that is, an image that represents you. For more information see, Adding Social Networking to your Website.

Gravatar.GetHtml(email, imageSize, defaultImage, rating, useFileExtension, attributes)

Gravatar,GetUrl(email, imageSize, defaultImage, rating, useFileExtension)

LinkShare

Renders social networking links using the specified title and optional URL. For more information see, Adding Social Networking to your Website.

LinkShare.GetHtml(pageTitle, pageLinkBack, twitterUserName, additionalTweetText, linkSites)

LinkShare.BitlyApiKey

LinkShare.BitlyLogin

Mail

Sends an email message. For more information, see Adding Email to your Website.

Mail.Send(to, subject, body, from, cc, filesToAttach, isBodyHtml, additionalHeaders)

Mail.EnableSsl

Mail.From

Mail.Password

Mail.SmtpPort

Mail.SmtpServer

Mail.SmtpUseDefaultCredentials

Mail.UserName

Recaptcha

Renders the reCAPTCHA verification test. The ReCaptcha helper displays an image of two distorted words that users have to enter correctly before the page is validated. The user response is validated by the ReCaptcha.Net service. For more information, see

Recaptcha.GetHtml(publicKey, theme, language, tabIndex)

Recaptcha.GetHtmlWithOptions(publicKey, options)

Recaptcha.Validate(privateKey)

Recaptcha.PrivateKey

Recaptcha.PublicKey

ServerInfo

Renders status information about ASP.NET Web Pages. For more information, see Introduction to Debugging.

ServerInfo.GetHtml()

Twitter

Renders a Twitter stream for the specified user. For more information see, Adding Social Networking to your Website.

Twitter.Profile(twitterUserName, width, height, backgroundShellColor, shellColor, tweetsBackgroundColor, tweetsColor, tweetsLinkColor, numberOfTweets, ScrollBar, loop, live, hashTags, timestamp, avatars, behavior, searchInterval)

Twitter.Search(searchQuery, width, height, title, caption, backgroundShellColor, shellColor, tweetsBackgroundColor, tweetsColor, tweetsLinksColor, scrollBar, loop, live, hashTags, timestamp, avatars, behavior, serachInterval)

Validation

Used to validate form fields and forms.

Validation.AddFieldError(key, errorMessage)

Validation.AddFieldError(key, errorFormat, args)

Validation.AddFormError(errorMessage)

Validation.AddFormError(errorFormat, args)

Validation.IsValid(fieldName)

Validation.ValidationHelper(WebPage)

Validation.Success

Video

Renders a video player used to play the specified file. For more information, see Working with Video.

Video.Flash(path, width, height, play, loop, menu, bgColor, quality, scale, windowMode, baseUrl, version, objectId, embedName, options)

Video.MediaPlayer(path, width, height, autoStart, playCount, uiMode, stretchToFit, enableContextMenu, mute, volume, baseUrl, objectId, embedName, options)

Video.Silverlight(path, width, height, bgColor, initParameters, minimumVersion, autoUpgrade, objectId, options)

WebImage

Provides capabilities to work with images. For more information, see Working with Images.

WebImage.AddImageWatermark(watermarkImage, width, height, horizontalAlign, verticalAlign, opacity, padding)

WebImage.AddTextwatermark(text, fontColor, fontSize, fontStyle, fontFamily, horizontalAlign, verticalAlign, opacity, padding)

WebImage.Clone

WebImage.Crop(top, left, bottom, right)

WebImage.FlipHorizontal()

WebImage.FlipVertical()

WebImage.GetBytes(requestedFormat)

WebImage.GetImageFromRequest(postedFileName)

WebImage.Resize(width, height, perserveAspectRatio, preventEnlarge)

WebImage.RotateLeft()

WebImage.RotateRight()

WebImage.Save(filePath, imageFormat)

WebImage.WebImage(content, format)

WebImage.WebImage(filePath, format)

WebImage.WebImage(imageStream, format)

WebImage.Write(requestedFormat)

WebImage.FileName

WebImage.Height

WebImage.ImageFormat

WebImage.Width

Other WebMatrix helpers include Chart, Crypto, ObjectInfo, WebCache, and WebGrid.

Of course, the above table related to WebMatrix BETA. The functionality may be updated. For additional syntax information, see the WebMatrix ASP.NET API Quick Reference.

Let me know if you are interested in examples or more specific syntax information. I would be happy to provide additional posts.

-- Erik Reitan
ASP.NET User Education
This posting is provided "AS IS" with no warranties, and confers no rights.