Prometheus Panelbar client-side/server-side

3 posts, 0 answers
  1. Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 08 May 2008 Link to this post

    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. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 10 May 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 10 May 2008 Link to this post

    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
Back to Top