Show Menu

Crownpeak Output.aspx Example Cheat Sheet by

Output.aspx example for Crownpeak
crownpeak

Example input.aspx

Input.ShowHeader("Contact Us");
Input.ShowTextBox("Page Title", "page_title");
Input.ShowAcquireImage("Contact Us Logo", "contact_us_logo");
Input.ShowTextBox("Contact Us Logo Alt Text", "contact_us_logo_alt_text");
Input.ShowWysiwyg("Address", "address", ServicesInput.FullWYSIWYG());
Input.ShowTextBox("Customer Service Phone", "customer_service_phone");
Input.ShowTextBox("Email", "email");
Place in Projec­t\T­emp­lat­es­\Som­eTe­mpl­ateName

Example Output­Helper Class

public static class OutputHelper
{
public static string OutputImage(OutputContext context, Asset asset, string imageAssetName, string altTextAssetName)
{
UploadedFile file = asset.UploadedFiles[imageAssetName];

if (file.IsLoaded)
{
Img img = Img.Load(file);

if (!img.HasError)
return string.Format("<img src='{0}' width='{1}' height='{2}' alt='{3}' />", file, img.Width, img.Height, asset[altTextAssetName]);
else if (!context.IsPublishing)
return string.Format("Error Loading image {0}. Error: {1}", img.ErrorMessage, imageAssetName);
}

return string.Empty;
}

public static string OutputMailTo(Asset asset, string emailAssetName, string linkText= null)
{
if (!string.IsNullOrEmpty(asset[emailAssetName]))
{
if (!string.IsNullOrEmpty(linkText))
return string.Format("<a href='{0}'>{1}</a>", asset[emailAssetName], asset[linkText]);
else
return string.Format("<a href='{0}'>{0}</a>", asset[emailAssetName]);
}

return string.Empty;
}
}
Place in Projec­t\L­ibrary

Example Output.aspx

<h1><%= asset["page_title"] %></h1>
<%= OutputHelper.OutputImage(context, asset, "contact_us_logo", "contact_us_logo_alt_text") %>
<p><%= asset["address"] %></p>
<p><%= asset["customer_service_phone"] %></p>
<p><%= OutputHelper.OutputMailTo(asset, "email") %></p>
Place in Projec­t\T­emp­lat­es­\Som­eTe­mpl­ateName

Result

Other Useful Helpers

<% var siteRootPath = Asset.GetSiteRoot(asset).AssetPath.ToString(); %>
<%= ServicesOutput.RenderCSSLink(siteRootPath + "/css/style.css") %>
<%= ServicesOutput.RenderScriptLink(siteRootPath + "/js/util.js") %>
<%= ServicesOutput.RenderHyperLink(asset, "buy_now") %>

Download the Crownpeak Output.aspx Example Cheat Sheet

2 Pages
//media.cheatography.com/storage/thumb/gregfinzer_crownpeak-output-aspx-example.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Crownpeak Input Controls Cheat Sheet
          Crownpeak Input Validation Cheat Sheet
          Crownpeak Models Cheat Sheet

          More Cheat Sheets by GregFinzer

          C# Naming Conventions Cheat Sheet
          Yarn Package Manager Cheat Sheet