Creating the products view

After you create the master list view and the details view, you must create the Products view control. Perform the following:

  1. From the context menu of folder Web » UI » Public, click Add » Class...

  2. In the Name input field, enter ProductsView.

  3. Open the file in Visual Studio and add the following namespaces:

    using Telerik.Sitefinity.Modules.Pages.Web.UI;
    using Telerik.Sitefinity.Web.UI.ControlDesign;
    using Telerik.Sitefinity.Localization;
    using Telerik.Sitefinity.Web.UI.ContentUI;
    using ProductCatalogSample.Web.UI.Public.Designers;

  4. Change the class definition to:

    [RequireScriptManager]
    [ControlDesigner(typeof(ProductsDesigner))]
    [PropertyEditorTitle(typeof(ProductsResources), "ProductsViewTitle")]
    public class ProductsView : ContentView


  5. Specify the module name by pasting this code:

    public override string ModuleName
    {
        get
        {
            if (String.IsNullOrEmpty(base.ControlDefinitionName))
                return ProductsModule.ModuleName;
            return base.ModuleName;
        }
        set
        {
            base.ModuleName = value;
        }
    }


  6. Specify a property that hides the prices on the frontend from the designer by pasting this code:

    public bool HidePrices
    {
        get
        {
            return this.hidePrice;
        }
        set
        {
            this.hidePrice = value;
        }
    }

  7. Specify the name of the configuration definition for the control in the following way:

    public override string ControlDefinitionName
     {
         get
         {
             if (String.IsNullOrEmpty(base.ControlDefinitionName))
                 return ProductsDefinitions.FrontendDefinitionName;
             return base.ControlDefinitionName;
         }
         set
         {
             base.ControlDefinitionName = value;
         }
     }

  8. Define the name of the master view:

    public override string MasterViewName
     {
         get
         {
             if (!String.IsNullOrEmpty(base.MasterViewName))
                 return base.MasterViewName;
             return ProductsDefinitions.FrontendListViewName;
         }
         set
         {
             base.MasterViewName = value;
         }
     }

  9. Define the name of the details view:

    public override string DetailViewName
     {
         get
         {
             if (!String.IsNullOrEmpty(base.DetailViewName))
                 return base.DetailViewName;
     
             return ProductsDefinitions.FrontendDetailViewName;
         }
         set
         {
             base.DetailViewName = value;
         }
     }

  10. Provide a property for the text that is shown when the box in the designer is empty:

    public override string EmptyLinkText
     {
         get
         {
             return Res.Get<ProductsResources>().EditProductsSettings;
         }
     }

  11. Save the file.

First, you set the control designer that the control uses. You do this by the ControlDesigner attribute. You define the control designer in Creating the products view control designer. Then, you specify the module name. After that, you set the name of the configuration definition that the control uses to construct the views. You create the definitions in Creating the frontend definitions. Finally, you define the views that are shown when the control is in theContentViewDisplayMode.Master and the ContentViewDisplayMode.Detail states. You reference the master list view and the details view.

Next steps

+1-888-365-2779
sales@sitefinity.com

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK