pass values in user controls

inzo21

Regular
Joined
Nov 5, 2003
Messages
74
Hello all.

ARRGGGHH! That's the word of the day!

I have a web site that has three panels on it - each with one or more user controls. The menu panel on the top has a single control as does the links panel on the left side. The content panel on the right has multiple user controls that pull infor from various xml files. The issue.

On the page load, I set the visibility of the user control (uc_home) to true - which is in the content panel. When the user clicks a button in the user control in the menu panel, I want it to alter the properties of the user controls in the content panel - particularly the visbility.

I successfully did this with HTML img objects and javascript code. But I need to do it using the asp:linkbutton object and, I guess, code behind.

Thus, I declared a property on the parent page and try to set that when the user control is selected. So if a user selects the linkbutton news, the property gets set to the value "news" which is then used in the PreRender method of the parent page to set the visibility of the uc_news control to true. It's not working. Here's the pertinent code for the parent page and the linkbutton. The contenttoload / ...tohide is used to load the new content and hide the previous content. These values are stored in session objects.

<---parent page--->

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
m_theuc = "proservices" '<- this is a member variable to hold uc value
OldContent = m_theuc
System.Diagnostics.Debug.WriteLine("from new: " & OldContent)
StartTime = Now()
Else

End If

End Sub
Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
ContentToLoad = CallUC
System.Diagnostics.Debug.WriteLine("uc from render:" & CallUC)
System.Diagnostics.Debug.WriteLine("old from render:" & OldContent)
System.Diagnostics.Debug.WriteLine("load from render: " & ContentToLoad)
Dim fullname As String = "uc_" & ContentToLoad
Dim oldfullname As String = "uc_" & OldContent

contenttohide = Me.FindControl(oldfullname)
contenttohide.Visible = False
contenttodisplay = Me.FindControl(fullname)
contenttodisplay.Visible = True

OldContent = ContentToLoad
End Sub

<---User Control--->

Private Sub linknews_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles linknews.Click
Dim test As xweb.index = New xweb.index
test.CallUC = "news"

End Sub

any ideas?
 
Back
Top