Hi Karen,
It would be somnething like this in C#:
// First create the tab panel
AjaxControlToolkit.TabPanel tabPanel1 =new AjaxControlToolkit.TabPanel();tabPanel1.ID ="tab1";// You could make this any value
tabPanel1.HeaderText ="text of tab";tabPanel1.TabIndex = 1; // where it appears from left to right
// Now you need to add it to the tabContainer
AjaxControlToolkit.TabContainer tc =new AjaxControlToolkit.TabContainer(); // if you already have a tabContainer, as I am sure you have by using the Design View, skip this line, go to the nexttc.Tabs.Add(tabPanel1); // If you created it in the design view, the tc is what you identified the TabContainer as.
Of course, you will need to add your code to dynamicaly populate multiple ones but this is how you create one tab panel from a code behind and add it to the TabContainer.
jgilmore,
Thanks for your answer.. do u think i would need a loop so that it will populate each... tab with the right user information.. something like
i can get arraylist of the users for that particular client and then give a for loop so it can name the tab panels 1 - n depending on the no. of users..
any ideas will be appreciated..
Regards
Karen
Hey Karen,
Yes that would work but you would also need to keep track of the tab index you assign to the user so you could associate what data to load based on what the index is. I am sure you could do this with the header text, too, but the problem with that method would be if you have two users with the same name.
but the userId's are unique...
Yes, I would assume the userids are unique. I may have misunderstood what the header text would display, userid or the name of the user, but you are on the right track.
actually i am gonna display the UserName as the header text and that should be unique too...
Thanks..
Regards
Karen
jgilmore:
Hi Karen,
It would be somnething like this in C#:
// First create the tab panel
AjaxControlToolkit.TabPanel tabPanel1 =new AjaxControlToolkit.TabPanel();tabPanel1.ID ="tab1";// You could make this any value
tabPanel1.HeaderText ="text of tab";tabPanel1.TabIndex = 1; // where it appears from left to right
// Now you need to add it to the tabContainer
AjaxControlToolkit.TabContainer tc =new AjaxControlToolkit.TabContainer(); // if you already have a tabContainer, as I am sure you have by using the Design View, skip this line, go to the nexttc.Tabs.Add(tabPanel1); // If you created it in the design view, the tc is what you identified the TabContainer as.
Of course, you will need to add your code to dynamicaly populate multiple ones but this is how you create one tab panel from a code behind and add it to the TabContainer.
this response was fantastic - thank you!
I'm just now trying to learn ajax too... I got your code to work after I put a PlaceHolder on the page and added the generated TabContainer control to PlaceHolder.Controls.Add()... it didn't work when I just tried to add the TabPanels to the TabDesigner I had created in Design View. But it works :)
So I have my Panels properly being dynamically created, but there is no content. I was hoping for .ContentTemplate or .innerHTML or .Text or something to which I could assign values to populate the panel contents. Does anyone have a link to a tutorial on how to dynamically populate the contents? Thanks a lot.
(this is my first post... this site is awesome)
jgilmore,
Which event should i create this tab panel dynamically? is it Tabcontainer.init method...
Regards
Karen
Hey Karen, I have always been able to create them in my Page_Load event. You shoudln't need to do the .init method on the tabcontainer.
Just be sure you are adding the tabPanels to the Tab Container and if your tab container has already been created in the design view, at run time the panels will attach to their parent control (the tabcontainer) which is contained on the page.
Let me know if you have any other questions,
John
Jgilmore.. how do i load the UserControl that i want to Display in my panel
PrivateSub CreateTabs()Dim oUserListAs ArrayList
Dim OUserAs iccUseroUserList = iccUser.GetUsersByClientId(System.Configuration.ConfigurationManager.AppSettings(APPSETTING_DBCONNECTION), Session("ClientId"))
ForEach OUserIn oUserListWith OUser
Dim iAsNew AjaxControlToolkit.TabPaneli.ID = OUser.UserID
i.HeaderText = OUser.LoginID
i.ContentTemplate = Page.LoadControl("WebUserControl.ascx", dg1.IUserId)TabContainer1.Tabs.Add(i)
EndWith
Next
EndSub
WebUserControl is a usercontrol where i would pass the Userid. but i am getting dg1 is not declared
<%@.ReferenceControl="~/WebUserControl.ascx" %>
<%@.RegisterTagName="Datagrids"TagPrefix="uc1"Src="~/WebUserControl.ascx" %>
<cc1:TabContainerID="TabContainer1"runat="server"ActiveTabIndex="0"OnClientActiveTabChanged="clientActiveTabChanged">
<uc1:DatagridsID="dg1"runat="server"/>
</cc1:TabContainer>
So how can i call the usercontrol in my template and specify the parameters..
Regards
Karen
Server Error in '/CPI' Application.
Specified argument was out of the range of valid values.
Parameter name: value
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: value
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.Stack Trace:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.Parameter name: value] AjaxControlToolkit.TabContainer.set_ActiveTabIndex(Int32 value) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\Tabs\TabContainer.cs:124 AjaxControlToolkit.TabContainer.OnInit(EventArgs e) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\Tabs\TabContainer.cs:285 System.Web.UI.Control.InitRecursive(Control namingContainer) +321 System.Web.UI.Control.InitRecursive(Control namingContainer) +198 System.Web.UI.Control.AddedControl(Control control, Int32 index) +2112991 System.Web.UI.ControlCollection.Add(Control child) +146 System.Web.UI.UpdatePanel.CreateContents(Boolean recreate) +162 System.Web.UI.UpdatePanel.OnInit(EventArgs e) +34 System.Web.UI.Control.InitRecursive(Control namingContainer) +321 System.Web.UI.Control.InitRecursive(Control namingContainer) +198 System.Web.UI.Control.InitRecursive(Control namingContainer) +198 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692
I am getting this error..
I am calling the Createtabs() in my page load section... but after i login...
any help will be appreciated.
regards
Karen
I am getting there.. i can see my tabs being generated dynamically?? but now i am stuck as to how to load my UserControl to it... and pass parameters...
any help will be appreciated..
Regards
Karen
No comments:
Post a Comment