Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 23rd, 2008, 12:09 PM
Authorized User
 
Join Date: Jun 2008
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Properties of Login control (p. 526)

Setting the VisibleWhenLoggedIn property of the Login control to False does not seem to have any effect when I do it. The PasswordRequiredErrorMessage and the UserNameRequiredMessage properties do not seem to have any effect either.

Does anyone have any idea what the causes of these problems could be?

Thank you for your trouble.

Roman
Reply With Quote
  #2 (permalink)  
Old June 23rd, 2008, 01:01 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

That's not how it's supposed to be. Can you tell me the page number of the code where this is not working? Page 526 only lists the properties.

If it's about code not discussed in the book, can you post it here?

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old June 23rd, 2008, 01:45 PM
Authorized User
 
Join Date: Jun 2008
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Thank you for your quick response to my question.

I started out with the files supplied for Chapter 14 and did the exercise on pages 520 to 523 ("Creating Login and Sign Up Pages").

I then went one step further and changed the VisibleWhenLoggedIn property of the Login control to False.

When I logged in, I was taken to the home page. So far, so good. I then clicked on the link "You can log in here," to go back to the login page, but when I got there, the login mask was still visible.

I also tried logging in without entering any information, whether a user name or a password, and the only thing that happened was that a red asterisk appeared next to each of the two fields. However, neither the PasswordRequiredErrorMessage ("Password is required") nor the UserNameRequiredErrorMessage ("User Name is required") showed up anywhere.

Here is the markup from the Login.aspx file:

<%@ Page Language="C#" MasterPageFile="~/MasterPages/MasterPage.master"
AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login"
Title="Log in to Planet Wrox" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">

    <asp:Login ID="Login1" runat="server"
        CreateUserText="Sign up for a new account at Planet Wrox now"
        CreateUserUrl="SignUp.aspx"
        VisibleWhenLoggedIn="False">
    </asp:Login>
    <asp:LoginStatus ID="LoginStatus1" runat="server" />

</asp:Content>

Here is the markup from the SignUp.aspx file:

<%@ Page Language="C#" MasterPageFile="~/MasterPages/MasterPage.master"
AutoEventWireup="true" CodeFile="SignUp.aspx.cs" Inherits="SignUp"
Title="Sign up for a new account at Planet Wrox" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">

        <asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
            <WizardSteps>
                <asp:CreateUserWizardStep runat="server" />
                <asp:CompleteWizardStep runat="server" />
            </WizardSteps>
        </asp:CreateUserWizard>

</asp:Content>

Here is the changed line from the ~/web.config file:

<authentication mode="Forms"/>

I used the Monochrome theme throughout.

Thank you very much for your trouble.

With best regards,

Roman
Reply With Quote
  #4 (permalink)  
Old June 23rd, 2008, 02:01 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
quote:When I logged in, I was taken to the home page. So far, so good. I then clicked on the link "You can log in here," to go back to the login page, but when I got there, the login mask was still visible.
On the actual Login page ASP.NET doesn't respect this setting. The Login control gets displayed regardless of VisibleWhenLoggedIn. That's why I wrapped it in a LoginView control. The setting works fine on other pages like About/Default.aspx

PasswordRequiredErrorMessage is only used in combination with a ValidationSummary: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.login.passwordrequireder rormessage.aspx
Quote:
quote:The PasswordRequiredErrorMessage property value is displayed only when both the following conditions are true:

- A ValidationSummary control is present on the page.
- The Password text box is left blank by the user.
With a Summary on the page, the actual error text is displayed. If you want to change the * to a custom Text, open the control's Smart Task panel, choose Convert to Template and then manually change the validation controls.


Hope this helps,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #5 (permalink)  
Old June 23rd, 2008, 03:17 PM
Authorized User
 
Join Date: Jun 2008
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Thank you again for a fast response.

I get the part about the validation summary now. Thank you. I should have remembered it from Chapter 9.

I also appreciate how nesting the Login control inside a LoginView control is an elegant way to deal with the visibility issue.

However, I don't completely understand what is meant about the setting not working on the login page, but working on others. For me, the login mask does not appear on any page except the login page, regardless of the value of VisibleWhenLoggedIn. Is this property only relevant when the Login control is implemented on a master page?

Sorry to keep bugging you with this issue, and thank you again for your trouble.

Cheers,

Roman
Reply With Quote
  #6 (permalink)  
Old June 24th, 2008, 03:06 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

The other way around. The property is ignored on Login.aspx.

This is not an arbitrary name: ASP.NET knows that the Login page is called Login.aspx in the root (although this can be configured).

Just for fun: add an <asp:Login /> control to About/Default.aspx and set the property. You'll see it works as expected....

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #7 (permalink)  
Old June 24th, 2008, 09:11 AM
Authorized User
 
Join Date: Jun 2008
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, Imar. So it is important to make the login page ~/Login.aspx. Very interesting. Cheers, Roman
Reply With Quote
  #8 (permalink)  
Old June 24th, 2008, 04:28 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

No, it's not important. As I hinted in my previous message, it can be configured. Add this to web.config:

<authentication mode="Forms">
  <forms loginUrl="SomeOtherpage.aspx" />
</authentication>

Now SomeOtherpage.aspx will be treated as the Login page.

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control properties in source view drmacy BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 4 September 25th, 2007 07:35 AM
Control properties in source view drmacy ASP.NET 2.0 Basics 5 September 17th, 2007 07:42 AM
Chp.5 composite control properties studen77 BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 1 October 6th, 2006 03:35 PM
Change the properties of a textbox control? marksartwork ASP.NET 1.0 and 1.1 Basics 7 April 4th, 2006 04:55 PM



All times are GMT -4. The time now is 10:39 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.