Show Menu
Cheatography

Crownpeak Output.aspx Example Cheat Sheet by

Output.aspx example for 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") %>

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi
 

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 Models Cheat Sheet
          Crownpeak Input Controls Cheat Sheet
          Crownpeak Input Validation Cheat Sheet

          More Cheat Sheets by GregFinzer

          Crownpeak Input Validation Cheat Sheet
          Node Package Manager Cheat Sheet