More in this section

Forums / Developing with Sitefinity / Register Custom Control

Register Custom Control

2 posts, 0 answered
  1. Jeff
    Jeff avatar
    8 posts
    Registered:
    08 Aug 2008
    14 Oct 2011
    Link to this post

    Hello,

    I must say in full disclosure that I have opened this same ticket as a support ticket but I am interested if the open forum is a more effective way to get timely support.

    So basically the following code fails because (I am assuming) there is something wrong with the following register:

    <%@ Register Assembly="Sitefinity.Widgets.Maps.Bing.BingMapWidget, Sitefinity.Widgets.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Namespace="Sitefinity.Widgets.Maps" TagPrefix="mps" TagName="LocationMap" %>

    If I attempt to refer to the above assembly:

    <mps:LocationMap id="map1" runat="server"></mps:LocationMap>

    I get an "unrecognized tag prefix or device filter: mps" If I try to load the DetailsView.ascx nothing displays. If I comment out the above lines then the detail location loads/displays correctly.

    The Maps assembly is referenced in the Location project and the associated dll is in the Locations bin. I also use this Maps widget as a registered toolbox widget for SF pages and that works perfect. Please take a look at the screen shot that shows what my evironment looks like. Basically I am trying to insert this map widget into my Location widget's detail view. Both the Locations and Maps widget are from the SF SDK. I currently am running SF4.2 build 1733.

    Thank you.

  2. Jeff
    Jeff avatar
    8 posts
    Registered:
    08 Aug 2008
    14 Oct 2011
    Link to this post
    I figured this out by getting a reference to the map project and setting the selected location in the ascx.cs and then inserting into a Placeholder control:
    <telerik:RadListView ID="DetailsView" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
        <LayoutTemplate>
            <asp:PlaceHolder ID="ItemsContainer" runat="server" />
        </LayoutTemplate>
        <ItemTemplate>
            <div class="column-small">
                <div class="block">
                ...
                <asp:PlaceHolder ID="phMap" runat="server"></asp:PlaceHolder>
                ...
                </div>
            </div>
        </ItemTemplate>
    </telerik:RadListView>
         
    protected override void InitializeControls(GenericContainer container, IContentViewDefinition definition)
    {
    DetailsViewControl.ItemDataBound += this.DetailsView_ItemDataBound;
    ...
    }
                 
    protected void DetailsView_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
    {
    RadListViewDataItem dataItem = e.Item as RadListViewDataItem;
    var item = dataItem as RadListViewItem;
    var ph = item.FindControl("phMap") as System.Web.UI.WebControls.PlaceHolder;
     
    var locationsView = (LocationsView)this.Host;
    var info = locationsView.DetailItem as LocationItem;
     
    var map = null as Sitefinity.Widgets.Maps.Bing.BingMapWidget;
    map = new Sitefinity.Widgets.Maps.Bing.BingMapWidget();
    map.Latitude = "39.525913";
    map.Longitude = "-74.647017";
    map.Street = info.Address;
    map.City = info.City;
    map.State = info.Region;
    map.Zipcode = info.PostalCode;
    ph.Controls.Add(map);
    }

    To complete this solution I will add Latetude and Lognitude properties to the Locations designer widget. Hope this helps someone else trying to accomplish the same sort of scenario.
2 posts, 0 answered