This is a migrated thread and some comments may be shown as answers.

Public Property on pageview

5 Answers 27 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
MBEN
Top achievements
Rank 1
Veteran
MBEN asked on 14 Oct 2013, 11:29 PM
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");

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 15 Oct 2013, 10:49 AM
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.

0
MBEN
Top achievements
Rank 1
Veteran
answered on 16 Oct 2013, 04:11 PM
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?
0
Shinu
Top achievements
Rank 1
answered on 17 Oct 2013, 06:00 AM
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.
0
MBEN
Top achievements
Rank 1
Veteran
answered on 17 Oct 2013, 04:36 PM
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?
0
Shinu
Top achievements
Rank 1
answered on 18 Oct 2013, 04:41 AM
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.

Tags
TabStrip
Asked by
MBEN
Top achievements
Rank 1
Veteran
Answers by
Shinu
Top achievements
Rank 1
MBEN
Top achievements
Rank 1
Veteran
Share this question
or