Access a server-side dynamic added multipage on client-side with javascript

2 posts, 0 answers
  1. Thorsten
    Thorsten avatar
    1 posts
    Member since:
    Feb 2012

    Posted 01 Feb 2012 Link to this post


    i have to access a multipage that was added dynamically on server-side on the client-side with javascript to make it visible and set the selected index.
    For example, a multipage that was added at designtime i access like this:
    function selectNews() {
                        var mV = $find("<%= radThumbs.ClientID %>");

    This works very well. But now i have to access a dynamically added multipage. All my attempts are without luck.
    In codebehind i set a unique id to each dynamic added multipage. In html-output that is generated the multipages are stored as div-tags with a id that is equal to that, that i set in codebehind on server-side.

    so far i tried different ways to get the control on client side.

    Attempt #1:
    alert('item.children[i].innerHTML.replace(/\s/g, "")');
    var test = $find(item.children[i].innerHTML.replace(/\s/g, ""));
    Attempt #2:
    alert('item.children[i].innerHTML.replace(/\s/g, "")');
    var test = document.getElementById(item.children[i].innerHTML.replace(/\s/g, ""));
    In all attempts the alertbox shows the correct id.
    But ever i try to set the selected index, a error occurs and tells me, that the element doesn't contain such a method and so on.

    Thanks for your assistence...

  2. Kate
    Kate avatar
    1898 posts

    Posted 03 Feb 2012 Link to this post

    Hi Thorsten,

    I created a simple page that you could test where I set the index of a dynamically created pageview using the client-side set_selectedIndex() method:

    <script type="text/javascript">
            function pageLoad() {
                var multiPage = $find("<%=RadMultiPage1.ClientID %>");
    //          var pageview1 = multiPage.findPageViewByID("Corporate1");
    //          pageview1.set_selected(true);
            <telerik:RadTabStrip ID="RadTabStrip1" SelectedIndex="0" runat="server" MultiPageID="RadMultiPage1">
            <telerik:RadMultiPage ID="RadMultiPage1" runat="server">

    code behind:
    protected void Page_Load(object sender, EventArgs e)
            if (!Page.IsPostBack)
                RadTab tab = new RadTab();
                tab.Text = "Corporate";
                Label lbl1 = new Label();
                lbl1.Text = "label1";
                RadPageView pageView = new RadPageView();
                pageView.ID = "Corporate";
                RadTab tab1 = new RadTab();
                tab1.Text = "Corporate1";
                Label lbl11 = new Label();
                lbl11.Text = "label11";
                RadPageView pageView1 = new RadPageView();
                pageView1.ID = "Corporate1";

    Kind regards,
    the Telerik team
    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 their blog feed now
Back to Top