Accessing controls in LoggedInView template

G

Guest

Hello,

I wanted to display a welcome message using the logged-in user's first name
in the <LoggedInTemplate> section of the LoginView. When I attempt to access
my welcome label control in the Page_Load event (where IsPostBack is true) to
populate with the user's first name from the Profiles table, it cannot find
the control. I've seen this question asked in other forums, and have tried
various ways to access the label control such as trying to access it in the
LoginView's ViewChanged event (which only fires in certain cases) to no
avail. What's the best way to attempt to access controls in the
LoggedInTemplate section? Can it be done? Thanks for any help.

-Mike
 
G

Guest

Mike,
First off with asp.net 2.0 authentication there is the possibility of a
logged in user to hit the page without a postback you replace ispostback with
"NEW" isauthenticated property.

Might be a better method with ITemplate but I don't know it also the logged
in template is not available unless user is logged in.

'findcontrol and ctype to label.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
if page.user.identity.isauthenticated then
Try
'somehow get first name into string or use page.user.identity.name
CType(LoginView1.FindControl("Label1"), Label).Text = firstname
Catch
End Try
endif
End Sub

Good Luck
DWS
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top