Property Get/Set Problem in User Control

D

David Hearn

I have a user control that acts as a header for the parent page that it is
sitting on. I was having some errors with it and per another users
suggestion in this newsgroup, it cleared up my problem by executing the
function from the PreRender event of my user control. I set the property's
value from the page load event of the parent form. Now, the problem is that
I am setting the property and I see it come in just fine, but by the time I
get to the function that uses it, it is set as Nothing again. What is wrong
with this and how do I fix it? Below is my code.

Thanks in advance!


Private strPageName As String
Public Property PageName() As String
Get
Return strPageName
End Get
Set(ByVal Value As String)
strPageName = Value
End Set
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs Handles MyBase.Load
If Not Page.IsPostBack Then
GetPaths()
End If
End Sub

Private Sub GetPaths()
GetPaths Code Here....
End Sub

Public Sub SetHeaderInfo(ByVal strPageHeader As String, Optional ByVal
strMessage As String = "")

'Set table display style
Select Case strPageName
Case "CreateEDIAccount"
Me.tblHeader.Attributes.Add("class", "IndWin")
tblHeader.Width = "100%"
Case "Invoice Detail", "CreditMemo Detail"
Me.tblHeader.Attributes.Add("class", "InvDtl")
Case Else
Me.tblHeader.Attributes.Add("class", "subcat")
End Select

lblPageHeader.Text = strPageHeader

If strPageName <> "CreateEDIAccount" And strPageName <> "Sales Terms"
Then
If Request.QueryString("SalesForce") <> "LogInAsTM" Then
lnkHome.Target = "_top"
lnkHome.NavigateUrl = sPathSecure & "/default.aspx"
Else
lnkHome.Target = "_top"
lnkHome.NavigateUrl = sPathSecure & "/admin/AccountList.aspx"
End If
End If

lblMessage.Text = strMessage

End Sub

Private Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.PreRender

SetHeaderInfo(strPageName)

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top