Results 1 to 5 of 5

Thread: Code in Master Page

  1. #1

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Code in Master Page

    I'm a real newbie when it comes to web apps.

    What I'd like to do is add some code to my .master page. The .master page has a Login control, and I'd like to display something like "Welcome, Guest" or "Welcome, Elvis" when the user is logged in.

    I added a label to the master page and tried to do something like
    Code:
    <asp:Label ID="lblWelcome" runat="server" Text="Welcome, <%=Login1.UserName %>" ></asp:Label>
    but even when successfully logged in, it just displays "Welcome,".

    I guess master pages don't have a code file associated with them? I'm not sure. Searched around, but I'm so ignorant I'm not sure what I'm looking for.

    Any help is appreciated, thanks.

    Mike

  2. #2
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    261

    Re: Code in Master Page

    I'm assuming you are using 2.0? If so its pretty easy, go to the Login Section on the toobar and drag in a "LoginStatus Control"

  3. #3

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: Code in Master Page

    Thanks for the reply, yes it's 2.0. I didn't know about the LoginStatus class - pretty nice.

    Still, I'd like to tweak it some. I can have the initial text say "Welcome, Guest", but where do I put the code to change that to "Welcome, seidel1" when you log in?

    Thanks,
    Mike

  4. #4
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    261

    Re: Code in Master Page

    You can edit the controls using edit template. Also you can put a label in before the controls.

    Check out the Wrox book Beginning ASP 2.0, there is a good section on this

  5. #5

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: Code in Master Page

    Fair enough, I need to do some reading. I have no idea yet what an edit template is, and although I could drop a label in, I still don't know how to manipulate it via code. That's my problem not yours

    I guess this would be a lot easier on me if a .master file had a code-behind file. If I had somewhere to write some code, I'd be ok I think.

    Thanks,
    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width