Reference a user control in code behind

VBAHole22

Contributor
Joined
Oct 21, 2003
Messages
432
Location
VA
I have a small user control that is a tabstrip that just controls page navigation around my site. I made it a web control so I could edit it only once. It works fine but I want to be able to modify it in code behind for each specific page but I can't seem to find a way to reference it in the code behind. Is there a way to do this?
 
I sort of figured out the answer but that brought up another issue.

I can reference my tabcontrol in my asp form by the following

Code:
 Protected TabControl1 As TabControl
 TabControl1 = DirectCast(FindControl("TabControl1"), TabControl)

I can also add a property on my tabcontrol that exposes the index and I can alter that.

My problem now is this. I have a tab control with 3 tabs. When the user clicks on any tab then the selected index in the tab control code behind page redirects them to the page they want. That page also has the same tab control up top. What I need is for the right tab to appear selected so the user know what page they are on.

The trouble is that each time you load up a new page it seems to load up a new tabcontrol and they default to having the first item selected. I can't seem to change that because I am trying to do it in the page load, but I think that might be too early.

Any suggestions?
 
Back
Top