Question

I have a label in a master page (lblUserCode) that contains the user identity code of the person logged in.

My Metrics page would need that user code to generate graphs for that specific person who logged in. Am I able to make use of the value of txtIdentity in the metrics page?

If so, how?

Thanks,

Poch

Update 1:

I tried the Master Page property approach:

I placed this in the Master Page:

Public Property ptyUserCode()
    Get
        Return lblUserCode.Text
    End Get
    Set(value)
        lblUserCode.Text = value
    End Set
End Property

The ptyUserCode and value have green lines under them with a message saying that "Property without an 'As' clause; type of object assumed."

In the Metrics page, I placed this:

Dim strUserCode = CType(Page.Master, Site).ptyUserCode

But it has a blue line underneath saying that 'ptyUserCode' is not a member of 'Site'. And true enough, my graph doesn't work :(

Update 2:

Placed this in the Master Page:

Private _UserCode As String = lblUserCode.Text

Public Property ptyUserCode() As String
    Get
        Return _UserCode
    End Get
    Set(value As String)
        _UserCode = value
    End Set
End Property

And then this in the Metrics page:

Dim strUserCode = Master.ptyUserCode

It gives me a page error, though :( it says that "'ptyUserCode' is not a member of 'System.Web.UI.MasterPage'."

:(

Was it helpful?

Solution

You can do something like

   Private _UserCode As String;
   Label lblUserCode = Page.Master.FindControl("lblUserCode");
   //_UserCode  = lblUserCode.Text 

Best Regards

OTHER TIPS

on you code-behind:

dim foo as string

foo = txtIdentity

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top