Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Splitter > Execute SplitterLoaded() code behind
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Answered Execute SplitterLoaded() code behind

Feed from this thread
  • Navnit avatar

    Posted on Mar 23, 2011 (permalink)

    Hi Telerik Admins,

    I am actually using this SplitterLoaded() function recommended by you to resize my RadSplitter initially.
    function SplitterLoaded(splitter, arg) {
                alert('<%= mainPane.ClientID %>');
                var pane = splitter.getPaneById('<%= mainPane.ClientID %>');
                var height = pane.getContentElement().scrollHeight;
                splitter.set_height(height);
                pane.set_height(height);
            }

    I was just wondering how do you execute the same function on subsequent ajax calls event. When I am actually clicking on the different Page Numbers of my asp.net Gridview control, I do have to calculate the height of the RadSplitter again because sometimes, the GridView height changes and becomes larger than the RadSplitter height set initially (which results in blinding some of the bottom parts of the grid view control).

    So one of the idea that I thought is to call the SplitterLoaded() function in the OnPageIndexChanging event

     string script = "SplitterLoaded(" + radSplitter + ", " + null + ");";
                    ScriptManager.RegisterStartupScript(updatePanelGridViewDefects, typeof(string), "key", script, true);

    - I'm sure the Eventargs of RadSplitter should not be null, but I have actually no idea of how to get the args object at this stage. 

    Might be there's a better way of doing it also ?

    Thanks for your help!

  • Answer Marin Bratanov Marin Bratanov admin's avatar

    Posted on Mar 25, 2011 (permalink)

    Hello Navnit,

    You do not need to use the code behind. An easier solution can be achieved client-side:
    • modify the function to not take any arguments and have it get a reference to the splitter by itself first (via the $find("<%=Splitter1.ClientID%>") method for example)
    • call the SplitterLoaded function on the OnPageIndexChanging event. You may first want to check whether you are going to show the page with the splitter (how to do that is explained in the following article: http://www.telerik.com/help/aspnet-ajax/datapager-onpageindexchanging.html
    • You could remove the alert() from the function, too, if it doesn't serve a practical purpose

    Using the RegisterStartupScript method could result in null reference errors, as AJAX controls are loaded after the window.onload event and if you try to use them before they are fully loaded you will get errors. For more information see the following blog post: http://blogs.telerik.com/supportdept/posts/09-05-05/executing_javascript_function_from_server-side_code.aspx.

    Greetings,
    Marin
    the Telerik team

  • Navnit avatar

    Posted on Mar 25, 2011 (permalink)

    Hi Marin

    Your solution works like a charm. You guys rocks as usual :)

    function SplitterLoaded() {
     
                var splitter = $find("<%=radSplitter.ClientID%>");
                var pane = splitter.getPaneById('<%= mainPane.ClientID %>');
                var height = pane.getContentElement().scrollHeight;
                var width = pane.getContentElement().scrollWidth;
                splitter.set_height(height);
                pane.set_height(height);
            }


    const string scriptstring = "SplitterLoaded();";
    ScriptManager.RegisterStartupScript(
    this, this.GetType(), "Loader", scriptstring, true);


    Thanks!
    Navnit

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Splitter > Execute SplitterLoaded() code behind