Image Gallery Webpart issue

Rahul Raghuvanshi asked on August 24, 2017 06:36

Hello,

In my Kentico 9 application, I am using Image Gallery webpart as control under a repeater webpart transformation and need to set Media Gallery webpart's "MediaLibraryPath" property dynamically.

Here is my repeater transformation code:

<%@ Register Src="~/CMSModules/MediaLibrary/Controls/LiveControls/MediaGallery.ascx" TagName="MediaGallery" TagPrefix="cms" %>

<cms:MediaGallery ID="gallery"  HideFolderTree="true" FileIDQueryStringKey="fileid" runat="server"  MediaLibraryName="ImageSets" TransformationName="Transformations.MediaLibrary_Showcase_Images"/>


<script runat="server">
  protected override void OnInit(EventArgs e) 
  {
      gallery.MediaLibraryPath = "_Showcase"; 
      gallery.ReloadData(true);
  }
</script>

But seems "MediaLibraryPath" properties not populating properly with above, instead of if trying like follows:

<cms:MediaGallery ID="gallery" MediaLibraryPath = "_Showcase" HideFolderTree="true" FileIDQueryStringKey="fileid" runat="server" MediaLibraryName="ImageSets" TransformationName="Transformations.MediaLibrary_Showcase_Images"/>

Getting expected result, but as per requirement need to set "MediaLibraryPath" dynamically from server script.

Please suggest what I am missing?

Thanks in advance.

Recent Answers


Suneel Jhangiani answered on August 24, 2017 11:11

I would hazard a guess that this is down to the Page Life Cycle and hence I would try overriding OnLoad instead of OnInit.

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on August 30, 2017 14:25

What are you trying to achieve here?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.