Monday, March 26, 2012

Access the control in Tabpanel on TabpanelContainer?

My second tab have some controls, ex. Textbox1, how can i access the value of Textbox1 in Tabpanel2 ?

Thanks,

I believe that Textbox1.Text should work for you... but I cannot try because I'm on diferent machine.


Hi,

Here is an example of referencing it with the help of FindControl method.

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server">
protected void Page_Init(object sender, EventArgs e)
{
TextBox tb = Panel2.FindControl("TextBox1") as TextBox;
tb.Text = DateTime.Now.ToString();

}

</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div><asp:Button runat="server" Text="Button" ID="Button1"></asp:Button>
<ajaxToolkit:TabContainer runat="server" Height="150px" ID="tbcPlanOverview" >
<ajaxToolkit:TabPanel runat="Server" ID="Panel1" HeaderText="Tab One">
<ContentTemplate>
PAGE ONE - Sample HTML Content for Tab
</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel runat="Server" ID="Panel2" HeaderText="Tab Two" >
<ContentTemplate>
PAGE TWO - Sample HTML Content for Tab
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ContentTemplate>
</ajaxToolkit:TabPanel
<ajaxToolkit:TabPanel runat="Server" ID="Panel3" HeaderText="Tab Three">
<ContentTemplate>
PAGE THREE - Sample HTML Content for Tab
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer> <br />
<asp:Image ID="Image1" runat="server" />
<asp:TextBox ID="txtTabSelect" runat="server" />
</div>
</form>
</body>
</html>

No comments:

Post a Comment