Accessing controls in LoggedInView template

Discussion in 'ASP .Net' started by Guest, Mar 7, 2006.

  1. Guest

    Guest Guest


    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.

    Guest, Mar 7, 2006
    1. Advertisements

  2. Guest

    Guest Guest

    First off with 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
    'somehow get first name into string or use
    CType(LoginView1.FindControl("Label1"), Label).Text = firstname
    End Try
    End Sub

    Good Luck
    Guest, Mar 8, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.