Public Property on pageview

6 posts, 0 answers
  1. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 14 Oct 2013 Link to this post

    I need to pass some information across the tabs and save all that information to the database on the submit button.
    I have some datatable and some other values that I need to pass on each tab.

    I was trying to create a public property and access the properties on the last tab but those peoperties don't show up against the usercontrol.
    Is it possible to access public properties? Is there any other way I can use the same datatable across all tabs?
    RadMultiPage multiPage = (RadMultiPage)this.NamingContainer.FindControl("rmChange");
    RadPageView pvStatus = multiPage.FindPageViewByID("Status");
    Control ucStatus = pvMaritalStatus.FindControl("StatusUserControl");
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 Oct 2013 Link to this post

    Hi MBEN,

    You can create a public variable in UserControl page code behind and access it in ASPX page by using ID of the UserControl . Please have a look into the following Code snippet.

    UserControl C#:
    public string test = "demo";

    ASPX:
    <uc1:WebUserControl ID="WebUserControl1" runat="server" />

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(WebUserControl1.test);
    }

    Thanks,
    Shinu.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 16 Oct 2013 Link to this post

    Hi Shinu,

    I actually wanted to access that property on another tab page.
    I have a tabstrip wizard setup just as in the demo. So there's a datatable and  string variable i populate on the first tab that i want to access across the other tabs.
    Any help?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Oct 2013 Link to this post

    Hi MBEN,

    Please have a look into the full code that I tried to access a string variable of one UserControl page in another UserControl page. Let me know if you need more help.

    ASPX :
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1">
        <Tabs>
            <telerik:RadTab Text="Tab1" PageViewID="RadPageView1">
            </telerik:RadTab>
            <telerik:RadTab Text="Tab2" PageViewID="RadPageView2">
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTabStrip>
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server">
    <telerik:RadPageView ID="RadPageView1"  runat="server">
        <uc1:WebUserControl ID="WebUserControl1" runat="server" />
    </telerik:RadPageView>
    <telerik:RadPageView ID="RadPageView2" runat="server" >
        <uc2:WebUserControl2 ID="WebUserControl21" runat="server" />
    </telerik:RadPageView>
    </telerik:RadMultiPage>

    UserControl Page1:
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
    <telerik:RadTextBox ID="RadTextBox1" runat="server">
    </telerik:RadTextBox>

    UserControl Page2:
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl2.ascx.cs" Inherits="WebUserControl2" %>
    <%@ Reference VirtualPath="WebUserControl.ascx" %>
    <telerik:RadTextBox ID="RadTextBox2" runat="server">
    </telerik:RadTextBox>
    <asp:Label ID="Label1" runat="server">
    </asp:Label>

    UserControl Page1 C#:
    public string test = "demo";

    UserControl Page2 c#:
    protected void Page_Load(object sender, EventArgs e)
    {
        WebUserControl control = (WebUserControl)Page.FindControl("WebUserControl1");
        Label1.Text = control.test;
    }

    Thanks,
    Shinu.
  6. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 17 Oct 2013 Link to this post

    Hi SHinu,

    I am not able to access the property/string variable as described in your scenario.
    Does it make a difference that the usercontrol declaration is donbe dynamically as shown in the demo here http://demos.telerik.com/aspnet-ajax/tabstrip/examples/application-scenarios/wizard/defaultcs.aspx.

    Can you give me an example using the demo decalrations as reference?
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Oct 2013 Link to this post

    Hi MBEN,

    I have worked with the demo and I am able to access the public string variable of one usercontrol page in another usercontrol page. Here is the sample code that I tried to access a public string variable of Flight usercontrol page in Passenger usercontrol page.

    Flight usercontrol C#:
    public string test = "demo";

    Passenger usercontrol:
    Please add this reference to the Passenger usercontrol page.
    <%@ Reference VirtualPath="FlightCS.ascx" %>

    Passenger usercontrol c#:
    protected void Page_Load(object sender, EventArgs e)
    {
        Flight control = (Flight)this.Page.FindControl("Flightusercontrol");
        string temp = control.test;
    }

    Please provide your code if it doesn't help.
    Thanks,
    Shinu.

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