I found this nice razorscript that looks in after a specific folder (1132 ) in the Media Libary and gives me the names and Ids of its Children... the script works as it's intended - however it's rather dirty and straight forward... - my point is that I need to do the very same in a usercontrol using a dynamic feed asp.net:DropDownList in order to get the SelecdedIndex... - I've NO clue hov to write something simular in a usercontrol
@inherits umbraco.MacroEngines.DynamicNodeContext
@using umbraco.MacroEngines;
@using umbraco.cms.businesslogic.media;
@{
var folderId = 1132;
var media = Model.MediaById(folderId);
var folders = media.Children;
<form method="post">
<select id="folderId" name="folderId" onchange="window.location.href = 'http://@Request.Url.Host/galleri/' + this.form.folderId.options[this.form.folderId.selectedIndex].value">
@foreach(var item in folders)
{
<option value="@item.Id">@item.Name</option>
}
</select>
</form>
}
It does'ne nessecary need to redirect though - it's just a feature... :-)
After a few (lots of) Googlesearches I finally succeded in creating above macroscript as a usercontrol... - the final resault looks as follows:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using umbraco.cms.businesslogic.media;
public partial class usercontrols_galleryTeaser : System.Web.UI.UserControl { private int _pathTo; public int PathTo { get { return _pathTo; } set { _pathTo = value; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int mediaId = PathTo; Media node = new Media(mediaId); var childrenNodes = node.Children;
Display mediaFolderIds in a usercontrol
I found this nice razorscript that looks in after a specific folder (1132 ) in the Media Libary and gives me the names and Ids of its Children... the script works as it's intended - however it's rather dirty and straight forward... - my point is that I need to do the very same in a usercontrol using a dynamic feed asp.net:DropDownList in order to get the SelecdedIndex... - I've NO clue hov to write something simular in a usercontrol
@inherits umbraco.MacroEngines.DynamicNodeContext @using umbraco.MacroEngines; @using umbraco.cms.businesslogic.media; @{ var folderId = 1132; var media = Model.MediaById(folderId); var folders = media.Children; <form method="post"> <select id="folderId" name="folderId" onchange="window.location.href = 'http://@Request.Url.Host/galleri/' + this.form.folderId.options[this.form.folderId.selectedIndex].value"> @foreach(var item in folders) { <option value="@item.Id">@item.Name</option> } </select> </form> }
It does'ne nessecary need to redirect though - it's just a feature... :-)
***Update***
After a few (lots of) Googlesearches I finally succeded in creating above macroscript as a usercontrol... - the final resault looks as follows:
Feel free to use anytime you whant... :-)
is working on a reply...