I need to know the name for "pageview" from usercontrol.

3 posts, 0 answers
  1. Jorge Saa-Gerbier
    Jorge Saa-Gerbier avatar
    22 posts
    Member since:
    Dec 2008

    Posted 12 May 2009 Link to this post

    Hi Telerik team,

    I have a tabStrip with multipage and each tab is the same usercontrol. I need to know the name for "pageview" from usercontrol in order to generate the code according to the name of "tab" and to avoid so many usercontrol as tabs (one for each tab) fulfilling this way the purpose of the usercontrol.

    Thanks for you help,
    Jorge Saa-Gerbier
  2. Paul
    Admin
    Paul avatar
    4281 posts

    Posted 13 May 2009 Link to this post

    Hi Jorge,

    Please find below a sample code snippet that shows the needed approach.

    Default.aspx
    <form id="form1" runat="server">  
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1">  
        </telerik:RadScriptManager> 
        <telerik:RadTabStrip ID="RadTabStrip1" runat="server" AutoPostBack="true" MultiPageID="RadMultiPage1">  
            <Tabs> 
                <telerik:RadTab runat="server" Text="Root RadTab1">  
                </telerik:RadTab> 
                <telerik:RadTab runat="server" Text="Root RadTab2">  
                </telerik:RadTab> 
                <telerik:RadTab runat="server" Text="Root RadTab3">  
                </telerik:RadTab> 
            </Tabs> 
        </telerik:RadTabStrip> 
        <telerik:RadMultiPage runat="server" ID="RadMultiPage1" RenderSelectedPageOnly="true">  
            <telerik:RadPageView ID="RadPageView1" runat="server">  
                RadPageView1<uc1:WebUserControl ID="WebUserControl1" runat="server" /> 
            </telerik:RadPageView> 
            <telerik:RadPageView ID="RadPageView2" runat="server">  
                RadPageView2<uc1:WebUserControl ID="WebUserControl2" runat="server" /> 
            </telerik:RadPageView> 
            <telerik:RadPageView ID="RadPageView3" runat="server">  
                RadPageView3<uc1:WebUserControl ID="WebUserControl3" runat="server" /> 
            </telerik:RadPageView> 
        </telerik:RadMultiPage> 
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
        </form> 

    WebUserControl.ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" 
        Inherits="WebUserControl" %> 
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> 

    WebUserControl.ascx.cs
    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Web;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using Telerik.Web.UI;  
     
    public partial class WebUserControl : System.Web.UI.UserControl  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
     
        }  
        protected void Button1_Click(object sender, EventArgs e)  
        {  
            RadMultiPage mp = (RadMultiPage)Page.FindControl("RadMultiPage1");          
            Label lbl = (Label)Page.FindControl("Label1");  
     
            lbl.Text = Convert.ToString(mp.SelectedIndex);  
        }  
    }  
     


    Sincerely yours,
    Paul
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Jorge Saa-Gerbier
    Jorge Saa-Gerbier avatar
    22 posts
    Member since:
    Dec 2008

    Posted 14 May 2009 Link to this post

    Hi Paul,

    Thank you for your answer, it was very useful, I succeeded.

    I just would like to mention that it's necessary to change:

    RadMultiPage mp = (RadMultiPage)Page.FindControl("RadMultiPage2");

     

    for:
     RadMultiPage mp = (RadMultiPage)this.Parent.Parent.Parent.FindControl("RadMultiPage2");

     

     

     

    that is to say, change Page for this.Parent.Parent.Parent.

    if not there's a exception failure of the type 'System.Web.HttpUnhandledException'.

    Sincerely yours,
    Jorge Saa-Gerbier.

Back to Top