Question

I would like to have an aspx page that contains something like....

<form id="form1" runas=server >
    Hello <%= Me.UserName() %>
</form>

and a code-behind something like...

Public Class Somepage
    inherits SomeOtherPage
    Private Readonly Property UserName() as String
    Get
        return "Rory"
    End Get
    End Property
End Class

I have tried this code but the aspx errors claiming that UserName is not declared.

What is the proper way to do this?

Was it helpful?

Solution

Mark the property as Protected, not Private.

Protected Readonly Property UserName() as String    
     Get        
          return "Rory"    
     End Get    
End Property
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top