Sitefinity not compiling in Thunder

Posted by Community Admin on 04-Aug-2018 16:25

Sitefinity not compiling in Thunder

All Replies

Posted by Community Admin on 25-Aug-2014 00:00

I'm working on a Sitefinity website were a lot of the custom widgets were built inside Sitefinity and not in Visual Studio.  They are a Mac shop and writing the c# code from an editor.  Now they brought me in to help them get some services working, but I can't compile because I get the error message:The name [Control Name] does not exist in the current context.   I'm not sure why I'm getting this as  the control is in the ascx file just like it should be.  Something's wrong because when I try to write my own widget using Thunder the templates are very different than these already written controls

BrandHero.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="~/Custom Widgets/BrandHero.cs" Inherits="SitefinityWebApp.CustomWidgets.BrandHero" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.DynamicModules.Web.UI.Frontend" TagPrefix="sf" %>     
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.Fields" TagPrefix="sf" %>     
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>     
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Modules.Comments.Web.UI.Frontend" TagPrefix="sf" %>     
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Modules.Libraries.Web.UI" TagPrefix="sf" %>     
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.PublicControls" TagPrefix="sf" %>
<%@ Import Namespace="Telerik.Sitefinity.Web.UI" %>
<%@ Import Namespace="Telerik.Sitefinity.Modules.Comments" %>
<sf:SitefinityLabel id="title" runat="server" WrapperTagName="div" HideIfNoText="true" HideIfNoTextMode="Server" CssClass="sfitemFieldLbl" />
<asp:Repeater id="detailContainer" runat="server">
    <ItemTemplate>
      <div class="sfitemDetails sfdetails brandHero clearfix"
            data-sf-provider='<%# Eval("Provider.Name")%>'
            data-sf-id='<%# Eval("Id")%>'
            data-sf-type="Telerik.Sitefinity.DynamicModules.Model.DynamicContent"
            style="background: Url('<%# Eval("HeroImage.Url") %>');">
        <div class="logo"><img src="<%# Eval("Logo.Url") %>"/></div>
        <div class="middleContent">
          <div class="description"><%# Eval("BrandMessage")%></div>
          <div class="socials">
            <a href="<%# Eval("Facebook")%>" class="symbol"></a>
            <a href="<%# Eval("Twitter")%>" class="symbol"></a>
            <a href="<%# Eval("GooglePlus")%>" class="symbol"></a>
            <a href="<%# Eval("YouTube")%>" class="symbol"></a>
            <a href="<%# Eval("Link")%>" class="link">GO TO <%# Eval("Link")%></a>
          </div>
        </div>
      </div>
    </ItemTemplate>
</asp:Repeater>

BrandHero.ascx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Sitefinity.DynamicModules;
using Telerik.Sitefinity.Utilities.TypeConverters;
using Telerik.Sitefinity.Web.UI;
using Telerik.Sitefinity.Web.UI.Fields;
using Telerik.Sitefinity.Web;
using Telerik.Sitefinity.Configuration;
using Telerik.Sitefinity.Web.Configuration;
using Telerik.Sitefinity.Web.UI.Fields.Contracts;
using System.Web.UI.HtmlControls;
using Telerik.Sitefinity.Modules.Pages;
 
namespace SitefinityWebApp.CustomWidgets
     
    public partial class BrandHero : System.Web.UI.UserControl
         
        protected override void OnInit(EventArgs e)
             
            base.OnInit(e);
             
            var dynamicModuleManager = DynamicModuleManager.GetManager();
            Type brandType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Brands.Brand");
             
            string urlParams = this.GetUrlParameterString(true);
            string selectedBrand = "";
             
            if (String.IsNullOrEmpty(urlParams))
                // No Params, 404
             else
                 
                // Parse URL params
                string[] querySegments = urlParams.Split('/');
                if(!String.IsNullOrEmpty(querySegments[1]))
                    selectedBrand = querySegments[1];
                    RouteHelper.SetUrlParametersResolved(true); // this prevents 404
                
                 
                // check if Brand is valid and get it
                var brand = dynamicModuleManager.GetDataItems(brandType).Where(b => b.UrlName == selectedBrand &&
                                                                                    b.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live);
 
<!-- Offending Lines -->
                detailContainer.DataSource = brand;
                detailContainer.DataBind();
                 
            
             
        
         
    
     

Posted by Community Admin on 28-Aug-2014 00:00

Hi,

I was able to set the UserControl you have provided and it is working correctly. The widgets generated by Thunder are custom controls, not WebUserControls, and inherit from SimpleView. Their way of operating and referencing layout and control in it is very different. The UserControls are simpler controls and in them you can directly work with the controls in the template. 
However, the error could be generated and caused by several things. First, please check if the control registered clr type or virtual path is the correct one in your solution. This could be done through  the back-end settings -> Advanced -> Toolboxes. Find your section and control and verify it. Check if the dynamic module type exists on your project. Check if the fields that will be shown in the template actually exists. You can also try debug the code and test whether an item is retrieved. Please, test also by showing only the Title field in the ascx controls.

Regards,
Nikola Zagorchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 28-Aug-2014 00:00

Thanks Nikolia,

I was able to solve the problem by using the following code:

var blogList = (Repeater)this.FindControl("blogList");
blogList.DataSource = snackChatBlogs;
blogList.DataBind();
It looks like it wasn't referencing the proper control.  I was going to follow your suggestion but the widgets were created with the builder inside Sitefinity by other programmers and I didn't want to screw something up.,  I was finally able to get all the kinks worked out.

Thanks Again!

Posted by Community Admin on 28-Aug-2014 00:00

Hi John,

You can directly use the control ID to operate with it only in UserControls and if the control is on first level and you have a designer class coming with the user control and the control codebehind. When using the FindControl(ID) you will get the base Control instance and should cast it to the control it is in order to access its properties.


Regards,
Nikola Zagorchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 28-Aug-2014 00:00

I tried creating a designer class in Visual Studio but that didn't help.  I'm guessing the designer class has to be created via Thunder.  I noticed that when I tried to make a user control via Thunder they are very different from what the Sitefinity builder creates.  So I'm thinking that's what happened here.

That's they get for letting Mac programmers do Windows Development... hahaha

Posted by Community Admin on 29-Aug-2014 00:00

Hello,

Sitefinity Thunder generates a 'boilerplate' with the base for a widget and a designer. You can also do this from scratch but it is time consuming to declare your designer class using Microsoft.Ajax in the JavaScript file. The widget can also be created from simple class, inheriting simple view and adding the control references and referencing your layout template by overriding the property.
I am glad you have managed to resolve the initial problem. Write back if we can help further.

Regards,
Nikola Zagorchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed