Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

Webforms for Marketers: show content item info

Modified: 2009/07/20 14:08 by jim - Categorized as: Sitecore
How to show content item info on your Web Forms for marketers forms using a custom Field Type.
- Inherit the control you want to use on the form.
- Implement the IResult interface if you want to use the value of the field in Actions.
- Implement IHasTitle to be able to render the title: Render Title

public class WfmFieldValueLabel : System.Web.UI.WebControls.Label , IHasTitle, IResult

- Add a Property to the control that can be used to enter the desired content item field:
private string fieldname;
[VisualProperty("SC fieldname:", 500)]
[VisualFieldType(typeof(EditField)), Localize]
public string FieldName
       return fieldname;
    set { fieldname = value; }

- Override the OnPreRender event to edit the desired control property

protected override void OnPreRender(EventArgs e)
// no tests - no catches - kept short for example purposes
    ID currentId = Sitecore.Context.Item.ID;
    Item currentItem = Sitecore.Context.Database.Items[currentId];
    this.Text = currentItem.Fields[fieldname].Value;


 © Evident Interactive BV