I would like to find the value of some textboxes that are on tabs in a WebTab control. At runtime the tabs are created and a user control is added to the tab for each record in a table. I need the values of the textbox that are on the user control for each tab. Is there a sample somewhere? I found an old sample for the UltraWebTab but not the WebTab control.
Thanks,
Stacey
Hello Stacey,
Thank you for contacting Infragistics!
The following forum thread discusses how to find a TextBox within a UserControl, of which is also within a WebTab:
http://ko.infragistics.com/community/forums/t/60679.aspx
If you have any questions, please let me know as well.
I am now able to find the control, but the text returned from the found control is an empty string although the tab and the textboxes on it seem to be displaying correctly. Here is the code for adding the tab to the WebTab
Dim newTab As New Infragistics.Web.UI.LayoutControls.ContentTabItem
Dim newControl As WUC_CCDetail = DirectCast(LoadControl("MyUserControl.ascx"),MyUserControl)
newTab.UserControlUrl = "MyUserControl.ascx"
newControl.Part = dRow!PartNumber.ToString (this is a public property on the user control that sets the txtPartNumber textbox text)
newTab.Text = dRow!PartNumber.ToString.Trim
newTab.Controls.Add(newControl)
WebTab1.Tabs.Add(newTab)
This seems to be working. The tab is added and the part Number textbox is filled in.
This is what I'm doing to try to get the text of the part number textbox:
Dim tempPart As String
Dim octl As Control = WebTab1.Tabs(0).FindChildControl("txtPartNumber")
If octl IsNot Nothing Then
tempPart = CType(octl, TextBox).Text
End If
It finds the txtPartNumber control but the text in it is an empty string.
It must have something to do with dynamically creating the user control and viewstate. Viewstate is enabled for all controls. Any suggestions?
I was over-complicating things. This works just fine.
Private Sub WebTab1_TabItemAdded(sender As Object, e As Infragistics.Web.UI.LayoutControls.TabItemEventArgs) Handles webTab1.TabItemAdded
e.TabItem.UserControlUrl ="/user_controls/myusercontrol.ascx"
WebTab1.SelectedIndex = WebTab1.Tabs.Count - 1
WebTab1.Tabs(WebTab1.SelectedIndex).FindChildControl("txtPartNumber").Focus()
End Sub
Hello steva,
Please let me know if you need further assistance.
Thank you for the update and details.
It is also possible that the event at which the textbox is being accessed is too early. I may need more information regarding the UserControl and the events at which the WebTab is created as well.