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.
I would hazard a guess that this is down to the Page Life Cycle and hence I would try overriding OnLoad instead of OnInit.
What are you trying to achieve here?
Please, sign in to be able to submit a new answer.