Web Page (HTML) Web Resources

[Applies to: Microsoft Dynamics CRM 2011]

Use webpage (HTML) web resources to create user interface elements for client extensions.

Capabilities of HTML Web Resources

Because an HTML web resource is just streamed to the user's browser, an HTML web resource can include any content that is rendered on the user's browser.

Limitations of HTML Web Resources

  • An HTML web resource cannot contain any code that must be executed on the server. ASP.NET pages cannot be uploaded as HTML web resources.

  • HTML web resources can only accept one custom query string parameter called "data".

Using the Text Editor for HTML Web Resources

The text editor provided in the Web Resource Form is intended for use with very simple HTML editing. For more sophisticated HTML documents, you should edit the code in an external editor and use the Browse button to upload the contents of your file.

For example, a more complex HTML page that requires script to render the contents of the page will begin like the following sample:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <script src="Script/Script.js" type="text/javascript"></script>
 <link href="CSS/Styles.css" rel="stylesheet" type="text/css" />
<body onload="SDK.ImportWebResources.showData()">
 <div id="results" />

After the document is opened in the text editor and saved, the HTML will be changed to this:

<META charset=utf-8></HEAD>
<BODY contentEditable=true onload=SDK.ImportWebResources.showData()>
<SCRIPT type=text/javascript src="Script/Script.js"></SCRIPT>
 <LINK rel=stylesheet type=text/css href="CSS/Styles.css">
<DIV id=results></DIV></BODY></HTML>

Prevent Editing of Web Resources for Managed Solutions

Because of the capability for the HTML in web resources to be changed by using the text editor, it is recommended that you use managed properties to set complex HTML web resources as not customizable for managed solutions. When viewing web resources in the solutions window, use the Managed Properties button to open the Managed Properties dialog box to set the Customizable property to false.

HTML Web Resource Tasks

The following sections show programming tasks related to using web resources.

Referencing Other Web Resources from an HTML Web Resource

You can create a set of related files outside of Microsoft Dynamics CRM that use any of the web resource file types. If you are careful to always use relative paths and import each web resource with a consistent naming convention that reflects the folder structure of your website, you will find that the HTML web resource will maintain links to related CSS, XML, JScript, image, and Silverlight files that have been imported as web resources.

For example, if you create a web application project that uses the following [folder]/file structure:

  • page.htm

  • [Styles]

    • style.css
  • [Scripts]

    • script.js

When you import these files as web resources, you can name in the following manner where your solution publisher customization prefix is ‘new’:

  • new_/page.htm

  • new_/Styles/style.css

  • new_/Scripts/script.js

When you follow this pattern, your new_/page.htmHTML web resource can reference the other files the most common way using relative paths. For example:

<script src="Scripts/script.js" type="text/javascript"></script>
<link href="Styles/style.css" rel="stylesheet" type="text/css" />

The solution publisher customization prefix becomes a virtual root folder for all the web resources in your solution. If you change your customization prefix, the relative paths within your HTML web resources will not be changed.


References included in code between web resources are not tracked as solution dependencies.

Because web resources are also downloaded for users of Microsoft Dynamics CRM for Microsoft Office Outlook with Offline Access, users will have access to web resource content while they are working offline.

Passing Parameters to HTML Web Resources

An HTML web resource can accept only the parameters in the following table.

Parameter Name Description


Entity Name

The name of the entity.


Entity Type Code

An integer that uniquely identifies the entity in a specific organization.


Object GUID

The GUID that represents a record.


Organization Name

The unique name of the organization.


User Language Code

The language code identifier being used by the current user.


Organization Language Code

The language code identifier that represents the base language for the organization.


Optional Data Parameter

An optional value that may be passed.


Form Id

The GUID that represents a form id.


For internal use only.


For internal use only.


For internal use only.

To pass more than one value in the data parameter, you must encode parameters in the value of the data parameter and then include logic to decode the multiple parameters using script in your HTML web resource. The Sample: Pass Multiple Values to a Web Resource Through the Data Parameter demonstrates one approach to address passing multiple parameter values.

Display an HTML Web Resource in a Form with No Border

When you add an HTML web resource to an entity form, a border will be displayed even when you do not check the Display Border check box of the formatting tab of the Web Resource Properties dialog box. To prevent a border from being displayed, set the style properties of the body element of the HTML document. You must also not include any DOCTYPE information. The following HTML will cause the HTML web resource contents to display without a border.

 <title>No Border Web Resource</title>
<body style="border-width: 0px; padding-left: 0px; padding-top: 0px; margin-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-right: 0px">
  This Web resource will display with no border</p>

By default, many HTML editors include DOCTYPE information in the contents of the HTML. The following HTML with the same body style applied will still appear with a border.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <title>Web Resource with Border</title>
<body style="border-width: 0px; padding-left: 0px; padding-top: 0px; margin-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-right: 0px;">
  Style applied but border still appears.</p>

See Also


Web Resources for Microsoft Dynamics CRM
Create Accessible Web Resources
Style Sheet (CSS) Web Resources
Script (JScript) Web Resources
Data (XML) Web Resources
Image (JPG, PNG, GIF, ICO) Web Resources
Silverlight (XAP) Web Resources
Stylesheet (XSL) Web Resources

Microsoft Dynamics CRM 2011
Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.