Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. How to get the logged in user

How to get the logged in user

Scheduled Pinned Locked Moved The Weird and The Wonderful
tutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NikoTanghe
    wrote on last edited by
    #1

    protected void Page_Load(object sender, EventArgs e)
    {
    IterateParentsForLoginId( Parent );
    }

    private void IterateParentsForLoginId(Control parent)
    {
    if (typeof( Page ).IsAssignableFrom( parent.GetType() ))
    {
    _loggedInId = ((Page)parent).LoggedInId;
    }
    else
    {
    if (parent.Parent != null)
    IterateParentsForLoginId( parent.Parent );
    else
    throw new InvalidOperationException(
    "To ensure proper page functioning, the containing page for this control must derive from OURNAMESPACE.Page." );
    }
    }

    << Nearly all men can stand adversity, but if you want to test a man's character, give him power. >>

    K 1 Reply Last reply
    0
    • N NikoTanghe

      protected void Page_Load(object sender, EventArgs e)
      {
      IterateParentsForLoginId( Parent );
      }

      private void IterateParentsForLoginId(Control parent)
      {
      if (typeof( Page ).IsAssignableFrom( parent.GetType() ))
      {
      _loggedInId = ((Page)parent).LoggedInId;
      }
      else
      {
      if (parent.Parent != null)
      IterateParentsForLoginId( parent.Parent );
      else
      throw new InvalidOperationException(
      "To ensure proper page functioning, the containing page for this control must derive from OURNAMESPACE.Page." );
      }
      }

      << Nearly all men can stand adversity, but if you want to test a man's character, give him power. >>

      K Offline
      K Offline
      Kevin Drzycimski
      wrote on last edited by
      #2

      the method should be called RecursiveParentsForLoginId

      M 1 Reply Last reply
      0
      • K Kevin Drzycimski

        the method should be called RecursiveParentsForLoginId

        M Offline
        M Offline
        Manfred Rudolf Bihy
        wrote on last edited by
        #3

        If rewritten properly this method is tail-recursive and thus ipso facto iterative (by nature).

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups