This is a migrated thread and some comments may be shown as answers.

RadTab, multi page view and dynamic RadPanelBar

1 Answer 31 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 12 Nov 2013, 01:35 PM
Hi

I am having an issue rooted in the RadTabBar with multi page view.

I am added a number of controls to a RadPanelBar.  I am adding HtmlGenericControls with hyperlinks to documents and an album control (other 3rd party) that binds to a list of files (jpeg, etc).  When I add this control the RadPanelBar, and add the RadPanelBar to the page (via a PlaceHolder), all works as expected.  I have my docs and my image album.

However, if I move the PlaceHolder into a RadTab, the RadPanelPar renders, the documents are present, the html shows the album (and supporting jscript), but does not seem to bind the actual images... they are not present.

Move the Placeholder out of the RadTab... all works again.

Here is the code oh how I am building all this up 

private void BuildAttachments()
        {
            List<String> photoPaths = new List<String>();
            List<String> docPaths = new List<String>();
            List<ServiceNote> notes = new List<ServiceNote>();
 
            Telerik.Web.UI.RadPanelBar panelBar = new RadPanelBar();
            panelBar.ID = ticketId.ToString();
            panelBar.ExpandMode = PanelBarExpandMode.SingleExpandedItem;
            panelBar.Width = 960;
 
            int y = 0;
            foreach (ServiceTicketTask task in ThisTicket.ServiceTicketTasks)
            {
                RadPanelItem panelItem = new RadPanelItem();
                panelItem.Text = task.ServiceItem.Name;
                panelBar.Items.Add(panelItem);
 
                panelItem.Enabled = false;
 
                foreach (ServiceNote note in task.ServiceNotes.Where(n => n.HasPictures).OrderBy(n => n.CreateDate))
                {
                    RadPanelItem panelNoteItem = new RadPanelItem();
                    panelNoteItem.Text = DateTimeFunctions.UtcToMyTime(note.CreateDate, _loggedInUser.TimeZoneId).ToString();
 
                    panelItem.Items.Add(panelNoteItem);
 
                    RadPanelItem panelImageItem = new RadPanelItem();
                    panelImageItem.Text = Labeling.Photos;
                    panelImageItem.Expanded = true;
                    panelNoteItem.Items.Add(panelImageItem);
 
                    RadPanelItem panelDocsItem = new RadPanelItem();
                    panelDocsItem.Text = Labeling.Documents;
                    panelDocsItem.Expanded = true;
                    panelNoteItem.Items.Add(panelDocsItem);
 
 
                    String photoPath = Storage.GetGalleryPath(ServiceTicket.MakeServiceTicketName(note.ServiceTicketTask.ServiceTicket.ServiceProvider.Abbrev, note.ServiceTicketTask.ServiceTicket.TicketName),
                                                                       note.ServiceTicketTask.CatalogItem.Name,
                                                                       note.CreateDate,
                                                                       Storage.DocumentGroups.Photos);
 
                    if (photoPath != null)
                    {
                        panelItem.Enabled = true;
 
                        String galleryID = String.Format("galleryServiceTickets_{0}", y);
 
                        GalleryBrowser galleryServiceTickets = new GalleryBrowser();
                        galleryServiceTickets.ID = galleryID;
                        galleryServiceTickets.Visible = true;
                        galleryServiceTickets.Width = 940;
                        galleryServiceTickets.Height = 50;
 
                        galleryServiceTickets.AllowEdit = false;
                        galleryServiceTickets.AllowPostComment = false;
                        galleryServiceTickets.AllowShowComment = false;
                        galleryServiceTickets.Layout = "Gridshow";
                        galleryServiceTickets.LogonUserName = _loggedInUser.FullName;
                        galleryServiceTickets.GalleryFolder = photoPath;
                        galleryServiceTickets.ToolTip = String.Format("{0} - {1}", note.ServiceTicketTask.ServiceItem.Name, note.CreateDate);
 
                        galleryServiceTickets.DataBind();
 
                        TemplateItem template = new TemplateItem(galleryServiceTickets);
                        template.InstantiateIn(panelImageItem);
                    }
 
                    String docPath = Storage.GetGalleryPath(ServiceTicket.MakeServiceTicketName(note.ServiceTicketTask.ServiceTicket.ServiceProvider.Abbrev, note.ServiceTicketTask.ServiceTicket.TicketName),
                                                                     note.ServiceTicketTask.CatalogItem.Name,
                                                                     note.CreateDate,
                                                                     Storage.DocumentGroups.Docs);
 
                    if (docPaths != null)
                    {
                        panelItem.Enabled = true;
 
                        List<String> filePaths = new List<String>();
                        filePaths = Storage.GetFileCount(docPath);
 
                        HtmlGenericControl divInner = new HtmlGenericControl("div");
                        divInner.ID = String.Format("DocDiv_{0}", y);
                        divInner.Attributes.Add("style""margin:0;padding:2px 0 0 6px;width:1000px;float:left;text-align:left");
 
                        Int32 i = 0;
 
                        foreach (String file in filePaths)
                        {
                            String newFile = file.Replace(HttpContext.Current.Server.MapPath(docPath), "").Replace("\\""");
                            String newFilePath = docPath + "/" + newFile;
 
                            HyperLink hlnkImage = new HyperLink();
                            hlnkImage.ID = String.Format("hlnkImage_{0}_{1}", y, i);
                            hlnkImage.ImageUrl = Utils.GetIcon(newFile);
                            hlnkImage.SkinID = "hlnkImage";
                            hlnkImage.NavigateUrl = newFilePath;
                            hlnkImage.Target = "_blank";
                            hlnkImage.ToolTip = newFile;
 
                            divInner.Controls.Add(hlnkImage);
 
                            TemplateItem template = new TemplateItem(divInner);
                            template.InstantiateIn(panelDocsItem);
 
                            i = i + 1;
                        }
                    }
 
                    y++;
                }
            }
            
            HtmlGenericControl scrollDiv = new HtmlGenericControl("div");
            if (notes.Count() > 15)
                scrollDiv.Attributes.Add("style""float:left;overflow:scroll;overflow-y:hidden; width:940px;");
            else
                scrollDiv.Attributes.Add("style""float:left; width:940px;");
 
 
            scrollDiv.Controls.Add(panelBar);
            plAttachments.Controls.Add(scrollDiv);
        }
 public class TemplateItem : ITemplate
    {
        Control control;
        #region ITemplate Members
        public void InstantiateIn(Control container)
        {
            container.Controls.Add(control);
        }
        #endregion
        public TemplateItem(Control ctrl)
        {
            control = ctrl;
        }
    }


I have moving the call to this method from the page_init to page_load, as well as calling it from within the load event of the tab itself.  In ll cases the results are the same.

I also moved all this code to a usercontrol and then added the usercontrol to the RadTab... same result

Thanks for any help...

1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 15 Nov 2013, 12:41 PM
Hello Daniel,

The approach you are currently using is the correct one and the controls are rendered in the PageView, where they are nested in - as you had also observed. Therefore, I would suggest you to make sure that you are using the correct approach for binding the mentioned 3rd part product. I would suggest you to verify if the photoPath is the correct one, once the controls are placed in the PageView.

Regards,
Nencho
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
TabStrip
Asked by
Daniel
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or