Accessing controls in LoggedInView template

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

  1. Guest

    Guest 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
     
    Guest, Mar 7, 2006
    #1
    1. Advertisements

  2. Guest

    Guest 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
     
    Guest, Mar 8, 2006
    #2
    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.
Loading...