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

Prometheus Panelbar client-side/server-side

2 Answers 84 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Waleed Seada
Top achievements
Rank 2
Waleed Seada asked on 08 May 2008, 02:16 PM

Dear all,

I use Panelbar on one of my user-controls which I placed in a pane of radsplitter on a master-page.

This panelbar is Ajaxified with other panel on the master-page.

I have a method (loadusercontrol) on the master-page that is called by this panelbar via (OnItemClicked) server side method, everything was fine until I notice that the method is called whenever I clicked on panelbar root-item or item, and I wanted to change this that the method is called on clicking the items only.

So, I think of doing this via client-side script, so I created a javascript method OnClientItemClicking="panelclicked" to handle this situation as follows:

<telerik:RadCodeBlock ID="CB1" runat="server">  
    <script type="text/jscript" language="javascript">  
        function panelclicked(sender, e)  
        {  
            var panelBar = $find("<%= navpanelBar.ClientID %>");  
            var item = panelBar.findItemByText(e.get_item().get_text());  
            if (item)  
            {  
                if item.get_text() == "AVT data"  
                {  
                    "<% MasterP.LoadUserControl("MainDataEntry.ascx", MasterP.MainPanel); %>"  
                }  
                else  
                {  
                }  
            }  
        }  
    </script> 
</telerik:RadCodeBlock> 
when I run the application I got this error:
"Script controls may not be registered after PreRender"

This error appear on the loadusercontrol method of the master-page:
public void LoadUserControl(string controlName, Control parent)  
    {  
        parent.Controls.Clear();  
        UserControl MyControl = (UserControl)LoadControl(controlName);  
        string userControlID = controlName.Split('.')[0];  
        MyControl.ID = userControlID.Replace("/""").Replace("~""");  
        parent.Controls.Add(MyControl);  
        CurrentControl = controlName;  
    } 

at that line : parent.Controls.Add(MyControl); 

any advice in this situation ...

Thanks and best regards
Waleed

2 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 10 May 2008, 11:32 AM
Hi Waleed ,

I suggest you just set PostBack property of the root items to False. Then OnItemClicked server side event will fire only for the items and you can use your first approach.

Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Waleed Seada
Top achievements
Rank 2
answered on 10 May 2008, 11:38 AM
Hello Rosi,
Thanks for your reply.

What If I need to make the root items clickable also as the items...
Is there any other way ...

Best regards,
Waleed
Tags
PanelBar
Asked by
Waleed Seada
Top achievements
Rank 2
Answers by
Rosi
Telerik team
Waleed Seada
Top achievements
Rank 2
Share this question
or