how to Find Controls in active tab in a tabcontainer control in asp.net

Posted by Ashish.shrma under ASP.NET AJAX on 4/19/2010 | Views : 13946 | Status : [Member] | Replies : 13
Dear All
I have a question about changing the properties of different textboxes together(or similar controls like buttons or so). Let me tell you the real problem.
What i want is that , i have 40 textboxes in different tabs on a single tab container.I want whenever i hit the clear button or any other option(palced on diffrent tabs) all the textboxes in the current tab should get cleared or enable , disable or readonly(whatever) with single click.. of the button(for the active tab only)
I don't want to make a subroutine or function in which i have to set the properties like
Sub CleatTextboxes()
txt1.text=""
txt2.text=""
txt3.text=""
txt4.text=""
txt5.text=""
txt6.text=""
txt7.text=""
end sub

Sub SetReadOnlyTrue()
txt1.readonly=True
txt2.readonly=True
txt3.readonly=True
txt4.readonly=True
txt5.readonly=True
txt6.readonly=True
txt7.readonly=True
end sub

Answer Should be like
For i=0 to Tabcontainer1.findcontrol(tab1).controls(textboxes).count
control(i).readonly=false
Control(i).text=""
next

or something more appropriate


Reply soon
Thank you for your earlier reply

Ashish


Responses

Posted by: Vuyiswamb on: 4/19/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
no use

 Page.FindControl("txt6");


Thank you for posting at Dotnetfunda
[Administrator]

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ashish.shrma on: 4/19/2010 [Member] Starter

Up
0
Down
Dear Vuyiswamb,
I already mentioned that i don't want to find individual control on the page. i want to find controls on the active tab of the Tabcontainer

Ashish

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/19/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Mybe am looking at it in a Different Dimension. The Controls in that Active Tab has names and what you need to do if so find which Tab is active and find the Controls that are in that Tab

Thank you for posting at Dotnetfunda
[Administrator]

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ashish.shrma on: 4/19/2010 [Member] Starter

Up
0
Down
Dear Vuyiswamb,

Now you are on right track
i want to do something like
For i=0 to Tabcontainer1.findcontrol(tab1).controls(textboxes).count
control(i).readonly=false
Control(i).text=""
next


Ashish

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/19/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Can i see the markup definition of your Tab Control and the Controls inside it

Thank you for posting at Dotnetfunda
[Administrator]

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ashish.shrma on: 4/19/2010 [Member] Starter

Up
0
Down
I have attached my aspx file for your refrence. I will be having more controls on the diffrent tabs according to their name. the later tabs are yet to be designed except address details
 Download source file

Ashish

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/19/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
i seem, But after all you need not to loop through Controls like that. What you can do is know them than look for them later (Early Binding and Late Binding Concept). What you can do know the Controls per Tab and identify the Tab and do what ever you want to do on the Controls based on the Tab selected. and i saw you tried to Find the controls in the level of the Tab. I think if you can say Page.FindControl it can find the control in the Tab easily and faster that way

Thank you for posting at Dotnetfunda
[Administrator]

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ashish.shrma on: 4/19/2010 [Member] Starter

Up
0
Down
Frist of all Thanks for your support. I have never seen such a quick reply in any forum at any site. But i really need it at individual tab level. But i am not able to do so. So can u just help me out. I have already implemented at page level but not able to do so it at individual tab level. Help me if you can

Ashish

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/19/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
i think this is exactly what you looking for
http://www.dotnetcurry.com/ShowArticle.aspx?ID=178

Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ashish.shrma on: 4/19/2010 [Member] Starter

Up
0
Down
Thanks alot,
I think this code will help me in acheiving what i want and
I am trying to make the code work according to my need.

Ashish

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/19/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Wonderfull.

Thank you for posting at DotneFunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenmanam on: 4/20/2010 [Member] Starter

Up
0
Down
use it

Page.FindControl("txt6");

NaveenKumar

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ashish.shrma on: 4/20/2010 [Member] Starter

Up
0
Down
Here comes another one !!!
Can we display a new web page with in tabcontainer's tabpanel.
Any working code will be highly appreciated.


Ashish

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response