+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / ButtonSelector provider

ButtonSelector provider

13 posts, 0 answered
  1. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    15 Oct 2010
    Link to this post
    Hi all,

    I'm using the ButtonSelector to select an image inside an IntraSite module.
    This is the code:

    <sfLib:ButtonSelector ID="imageSelector" WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageDialog.aspx"
                            ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx"
                            AssociatedControls="mainImageId" runat="server" CssClass="pickerWrapper" ButtonText="Select" />

    The thing is that it is showing the libraries from the default provider, but I want to select libraries from another provider. How can I do this?

    Regards,
    Daniel
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Oct 2010
    Link to this post
    Hello Daniel,

    Open Sitefinity\UserControls\Dialogs\ImageDialog.aspx and there is the declaration of ItemSelector control from where you can set ProviderName property.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    18 Oct 2010
    Link to this post
    Thanks Ivan!

    What is the ItemTemplatePath doing? It refers to:
    ="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx"

    Is this the actual template? Because it points to /News/ so that is quite specific?

    Regards,
    Daniel
  4. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    18 Oct 2010
    Link to this post
    Hmm.. still having trouble to get it working.
    I've copied the 'ImageDialog.aspx' file to a custom location, because I don't want the provider to be changed for all the ImageSelectors.

    The selector works, I can click the 'Select' button inside my template. Then a popup opens with the ability to choose a library from the right provider. Now when I try to open a library to select an image I get an error:

    Object reference not set to an instance of an object.


    Did I forgot something?

    Groet,
    Daniel


  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Oct 2010
    Link to this post
    Hello Daniel,

    The only thing that you have to do is changing the provider name in ImageDialog.aspx file. The ItemSelector uses Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\ItemSelector.ascx template to show the data, so make sure that you have this template as well and it has not been modified.

    The " Object reference error" means that something at your end returns null and the stack of the error would provide some more details.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    18 Oct 2010
    Link to this post
    Okay, thanks.
    Clear how it works.

    The stacktrace is:
    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Libraries.WebControls.ItemView.CreateChildControls() +107
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.Control.PreRenderRecursiveInternal() +44
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

    That's all.

  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Oct 2010
    Link to this post
    Hello Daniel,

    The container - ItemViewContainer is null or there are no data items. Unfortunately, I cannot tell you what the problem is without a sample project. I cannot reproduce the issue at my end.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    18 Oct 2010
    Link to this post
    Hello Ivan,

    It has something to do with the ProviderName I set.
    If I don't set a Provider, then everything works as expected.

    So, when I set the ProviderName I can choose from the libraries that this provider offers. If you click on a library, then it is going to load the images from that library. Should this ImageSelector also have a reference to the Provider somewhere?

    Greetings,
    Daniel
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Oct 2010
    Link to this post
    Hi Daniel,

    You have to set the provider directly inside ItemsView declaration

    Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\ItemSelector.ascx

    <li runat="server" id="itemLi">
        <sfLib:ItemView ProviderName="LibrariesProvider1" ID="contentView" runat="server" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/Libraries/SelectorItemView.ascx" />
    </li>


    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    19 Oct 2010
    Link to this post

    Hi Ivan,

    This is the code inside my template:

    <sfLib:ButtonSelector ID="imageSelector"    WindowNavigateUrl="~/Custom/UserControls/Sitefinity/ImageDialog.aspx" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx" AssociatedControls="mainImageId" runat="server" CssClass="pickerWrapper" ButtonText="Select" />

    I copied the file 'ImageDialog.aspx' to a custom location, because I don't want to override the default one:
    ~/Custom/UserControls/Sitefinity/ImageDialog.aspx

    I changed it like this:
    <lib:ItemSelector ProviderName="Photos" runat="server" AllowPageSelection="false" ShowMode="Images" />

    So, according to your last post this should work?
    What about the ItemTemplatePath? Is this the correct one?

    -Daniel-


  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    19 Oct 2010
    Link to this post
    Hi Daniel,

    ItemView uses its own template - SelectorItemView.ascx

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    19 Oct 2010
    Link to this post
    Okay, now I've lost it.

    1. I use ButtonSelector
    2. I point to the ImageDialog.ascx.
    3. I added the ProviderName inside the ImageDialog.ascx.

    What about ItemView uses its own template - SelectorItemView.ascx?
    For as far as I know, I don't use ItemView?

    Daniel
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    19 Oct 2010
    Link to this post
    Hello Daniel,

    ItemSelector calls ItemsView and ItemsView uses its own template. You have to set the ProviderName to the ItemsView.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
13 posts, 0 answered