protected override void OnLoad(EventArgs e)
 {
     Assert.ArgumentNotNull(e, "e");
     base.OnLoad(e);
     if (!Context.ClientPage.IsEvent)
     {
         if (!WebDAVConfiguration.IsWebDAVEnabled(true))
         {
             this.OpenWebDAVViewButton.Visible = false;
         }
         MediaBrowserOptions options = MediaBrowserOptions.Parse();
         Item root = options.Root;
         if (root != null)
         {
             this.MediaDataContext.Root = root.ID.ToString();
         }
         Item selectedItem = options.SelectedItem;
         if (selectedItem != null)
         {
             this.MediaDataContext.Folder = selectedItem.ID.ToString();
         }
         Item folder = this.MediaDataContext.GetFolder();
         Assert.IsNotNull(folder, "Item not found.");
         this.UpdateSelection(folder);
     }
 }
        protected override void OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(args, "args");
            MediaBrowserOptions options = MediaBrowserOptions.Parse();
            string str = this.Filename.Value;

            if (options.AllowEmpty && string.IsNullOrEmpty(str))
            {
                SheerResponse.SetDialogValue(string.Empty);
                base.OnOK(sender, args);
            }
            else if (string.IsNullOrEmpty(str))
            {
                SheerResponse.Alert(Translate.Text("Select a media item."), new string[0]);
            }
            else
            {
                Item root = this.MediaDataContext.GetRoot();
                if ((root != null) && (root.ID != root.Database.GetRootItem().ID))
                {
                    str = FileUtil.MakePath(root.Paths.Path, str, '/');
                }
                Item item = this.MediaDataContext.GetItem(str);
                if (item == null)
                {
                    SheerResponse.Alert(Translate.Text("The media item could not be found."), new string[0]);
                }
                else if (IsFolderItem(item))
                {
                    this.MediaDataContext.SetFolder(item.Uri);
                }
                else
                {
                    SheerResponse.SetDialogValue(item.ID.ToString());
                    base.OnOK(sender, args);
                }
            }
        }