URGENT:Load On Demand RadPanelBar with MultiPage

16 posts, 0 answers
  1. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 30 Sep 2011 Link to this post

    • CASE SCENARIO : 
    I have a rad panel bar as you can see it in the code below,a MultiPage and 2 usercontrols..

    • WHAT I WANT:
    1. Whenever we click on any item in the panel , new pageview gets created from code-behind , the ID of pageview is same as value of item getting clicked, the pageview dynamically loads an usercontrol (refer C# code) 
    2. The Panel clicking also fires a javascript event in which if the pageview is already loaded it simply displays that pageview without any server-side event or postback occuring(refer javascript code)
    WHAT IS THE PROBLEM IN MY CODE? WHY AIN'T IT WORKING THE WAY IT IS EXPECTED TO ? Thanks

    ASPX CODE:
    <telerik:RadPanelBar  style="margin-left:8px;" ID="RadPanelBar1" Runat="server" Skin="Office2007"
        Width="210px" onitemclick="RadPanelBar1_ItemClick" OnClientItemClicked="onitemclick">
        <Items>
            <telerik:RadPanelItem runat="server"
                Owner="RadPanelBar1" Text="Speak & Listen.." Expanded="True">
                <Items>
                    <telerik:RadPanelItem runat="server" Owner=""
                        Selected="True" Text="Friends News Feed" Value="nfeed">
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem runat="server"
                         Owner=""
                        Text="Following Public Profiles" Value="try">
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelItem>
    </telerik:RadPanelBar>
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server" OnPageViewCreated="RadMultiPage1_PageViewCreated">
       </telerik:RadMultiPage>
    C# CODE
    protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
       {
              
       }
       protected void RadPanelBar1_ItemClick(object sender, RadPanelBarEventArgs e)
       {
             
               RadPageView pager = new RadPageView();
               pager.ID = e.Item.Value.ToString();
               Control userControl = Page.LoadControl("Newsfeed/" + e.Item.Value.ToString() + ".ascx");
               userControl.ID = e.Item.Value.ToString() + "usercontrol";
               pager.Selected = true;
               pager.Controls.Add(userControl);
               RadMultiPage1.Controls.Add(pager);
       
              
       }

    JAVASCRIPT CODE
    function onitemclick(sender, args) {
                 var multiPage = $find("<%=RadMultiPage1.ClientID%>");
                 var item = args.get_item();
                 var itemt = item.get_value();
                 if (multiPage.get_pageViews().get_count() > 2) {
                     for (var i = 0; i < multiPage.get_pageViews().get_count(); i++) {
                         if (multiPage.get_pageViews().getPageView(i).get_id() == itemt) {
     
                             var pageView = multiPage.findPageViewByID(itemit);
                             pageView.set_Selceted(true);
                             pageView.show();
                             item.set_postBack(false);
                         }
                     }
                 }
                 
             }
  2. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 01 Oct 2011 Link to this post

    Teleik Admins can't crack this yet ?? why it is taking so much of time??
    With best hopes and regards,
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 04 Oct 2011 Link to this post

    Hello Vaibhav,

    Try to load the user control in the OnPageViewCreated event handler function of the RadMultiPage as shown in this demo here.

    Greetings,
    Dimitar Terziev
    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
  5. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 05 Oct 2011 Link to this post

    Changed my .aspx.cs code to ..
    protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
      {
          Control userControl = Page.LoadControl("Newsfeed/" + e.PageView.ID.ToString() + ".ascx");
          userControl.ID = e.PageView.ID.ToString() + "usercontrol";
          e.PageView.Selected = true;
          e.PageView.Controls.Add(userControl);
          RadMultiPage1.Controls.Add(e.PageView);
      }
      protected void RadPanelBar1_ItemClick(object sender, RadPanelBarEventArgs e)
      {
          
              RadPageView pager = new RadPageView();
              pager.ID = e.Item.Value.ToString();
      }
    but still not working .. if that's what u were trying to say Mr.Dimitar Terziev is their anything else that could work??
  6. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 06 Oct 2011 Link to this post

    Hello Vaibhav,

    The reason for the experienced behavior is the fact that you should add the newly created pageview to the PageViews collection of the mutlipage in order the PageViewCreated event to be fired.

    First you are adding the pageview in the wrong moment , second you are not using the appropriate collection. Change your code as following:
    protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
      {
          Control userControl = Page.LoadControl("Newsfeed/" + e.PageView.ID.ToString() + ".ascx");
          userControl.ID = e.PageView.ID.ToString() + "usercontrol";
          e.PageView.Selected = true;
          e.PageView.Controls.Add(userControl);
           
      }
      protected void RadPanelBar1_ItemClick(object sender, RadPanelBarEventArgs e)
      {

          RadPageView pager = new RadPageView();
          pager.ID = e.Item.Value.ToString();
          RadMultiPage1.PageViews.Add(pager);
      }


    Regards,
    Dimitar Terziev
    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
  7. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 09 Oct 2011 Link to this post

    Respected Dimitar ,
    Apparently the JavaScript code does not work as it is expected , i have changed my code-behind code as you asked but still i am unable to achieve what i was aiming for .
    <script type="text/javascript">
     
            function onitemclick(sender, args) {
                var multiPage = $find("<%=RadMultiPage1.ClientID%>");
                var item = args.get_item();
                var itemt = item.get_value();
                if (multiPage.get_pageViews().get_count() > 0) {
                    for (var i = 0; i < multiPage.get_pageViews().get_count(); i++) {
                        if (multiPage.get_pageViews().getPageView(i).get_id() == itemt) {
                            var pageView = multiPage.findPageViewByID(itemit);
                            pageView.set_Selceted(true);
                            pageView.show();
                            item.set_postBack(false);
                        }
                    }
                }
     
            }
                 
     
            </script>
    As given in the demo(mentioned in your above post) ,after the person clicks on the the tab second time or third time .....it loads the pageview which is already loaded in the page , i am trying to do same with the panel bar but as it does not have a property of 'PageviewID' some problem is occurring. Please go through my code and tell where i could be wrong... . The code is in <div runat="sever">//JavaScript code</div>

  8. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 11 Oct 2011 Link to this post

    I am using Ajax Manager could that be a problem?
  9. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 12 Oct 2011 Link to this post

    Hello Vaibhav,

    Try to disable the Ajax and check whether the problem persists. In case the problem is related to the Ajax then provide the Ajax setting that you are using.

    Kind regards,
    Dimitar Terziev
    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
  10. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 16 Oct 2011 Link to this post

    I disabled ajax but it does not work any ideas why so ???
  11. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 23 Oct 2011 Link to this post

    Telerik Adimns ill or what??? can't figure this out yet?? hlp needed ...
  12. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 27 Oct 2011 Link to this post

    Hello Vaibhav,

    I've prepared a sample page demonstrating how to achieve the desired functionality.

    All the best,
    Dimitar Terziev
    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
  13. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 28 Oct 2011 Link to this post

    Thank you , sir ..
    that example worked well, thank you ...
    the only problem which needs to be corrected is ..
    protected void RadMultiPage1_PageViewCreated(object sender, Telerik.Web.UI.RadMultiPageEventArgs e)
       {
           Control userControl = Page.LoadControl("UserControls/" + e.PageView.ID.ToString() + ".ascx");
           userControl.ID = e.PageView.ID.ToString() + "usercontrol";
           e.PageView.Selected = true;
           e.PageView.Controls.Add(userControl);
       }

     Page.LoadControl("UserControls/" + e.PageView.ID.ToString() + ".ascx");
    needs to be changed to 
     Page.LoadControl(e.PageView.ID.ToString() + ".ascx");

    Thanking Telerik team for showing late but good support ..
  14. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 22 Dec 2011 Link to this post

    Going through your solution I incurred a little problem : if i click on a button twice in the usercontrol it redirects me to another usercontrol!!?? why it is so ??
  15. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 25 Dec 2011 Link to this post

    Somebody please help!!
  16. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 27 Dec 2011 Link to this post

    Hi Vaibhav,

    I've prepared a sample page trying to reproduce the experienced problem, but to no avail. You could find it attached.

    Could you provide more information for your particular implementation? Do you handle the button click event and if so what is the custom logic that you are using in the event handler function?

    All the best,
    Dimitar Terziev
    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
  17. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 20 Jan 2012 Link to this post

    Well , I think so i have got the solution ..
    the problem was their was a input having id as RadMultiPage1_ClientState with value="{"selectedIndex":0,"changeLog":[]}"  now whenever i used to postback ...the first time the postback used to work fine ,but the textbox/input's  value would change to null ,
    and thus the RadMultiPage would not know which Pageview is seleceted ..
    Hence, if u ajaxify the usercontrols they would work upto your expectations ...as the textbox value will not change
    thanks for your help ...
    Regards 
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017