Error adding pageview from client side.

5 posts, 1 answers
  1. JC
    JC avatar
    30 posts
    Member since:
    Feb 2013

    Posted 28 Feb 2013 Link to this post

    Hi,

    Here is the skeleton of my aspx page in which I am trying to add  a pageview from client side. The JS shows no error but the code is not working as expected. Please let me know whats the mistake in the code.

    <telerik:RadTabStrip ID="RadTabStripBoard" runat="server" MultiPageID="RadMultiPage1">
       <Tabs>
           <telerik:RadTab runat="server" Text="Gifts">
           </telerik:RadTab>
           <telerik:RadTab runat="server" Text="Coupons">
           </telerik:RadTab>
       </Tabs>
    </telerik:RadTabStrip>   
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server">           
    </telerik:RadMultiPage>
    <telerik:RadButton ID="Add" runat="server" OnClientClicked="AddTab">
    </telerik:RadButton>
    <script>
       function AddTab(sender, args)
       {           
           var multiPage1 = $find("<%=RadMultiPage1.ClientID %>");                       
           var pageView = new Telerik.Web.UI.RadPageView();     
           multiPage1.get_pageViews().add(pageView);          
       
    </script>
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Feb 2013 Link to this post

    Hello,

    Try the following JavaScript to add page view from client side.

    JavaScript:
    <script type="text/javascript">
        function AddPage() {
            var multiPage1 = $find("<%=RadMultiPage1.ClientID %>");
            multiPage1.trackChanges();
            var pageView = new Telerik.Web.UI.RadPageView();
            multiPage1.get_pageViews().add(pageView);
            pageView.get_element().innerHTML = "Gift PageView";
            multiPage1.commitChanges();
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 05 Mar 2014 in reply to Princy Link to this post

    Hello Princy

    it's doesn't work if we don't add <telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">

    to help someone : test on Q1 2014

    <telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
        <script type="text/javascript">
            function AddPage() {
               var multiPage1 = $find("<%=RadMultiPage1.ClientID %>");
               multiPage1.trackChanges();
               var pageView = new Telerik.Web.UI.RadPageView();
               multiPage1.get_pageViews().add(pageView);
               pageView.get_element().innerHTML = "Gift PageView";
               multiPage1.commitChanges();
            }
          </script>
     </telerik:RadCodeBlock>
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2014 in reply to Olivier Link to this post

    Hi Olivier,

    RadCodeBlock should be used when you have server code blocks placed within the markup (most often some JavaScript functions accessing server controls). Please have a look into this help article for further information about RadCodeBlock.

    Thanks,
    Princy.
  6. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 06 Mar 2014 Link to this post

    Thanks Princy,

    i search for a long time, so may be it help someone , to write this answer.

    Cause When i copy you demo code , it's doesn't plug n play


    olivier
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017