I'm having troubles getting a userlogin validation up and running. The login itself works fine, but i need some form of errorhandling on logging in with wrong credentials.

My code so far looks like this:

<%@ Master Language="C#" MasterPageFile="/masterpages/PageWithoutLeftmenu.master" AutoEventWireup="true" %>
<%@ Import Namespace="System.ComponentModel" %>

<script runat="server">
void OnLoginError(object sender, EventArgs e)
{
    Login1.HelpPageText = "Help with logging in...";
    Login1.PasswordRecoveryText = "Forgot your password?";
}

</script>

	
<asp:Content ContentPlaceHolderID="phPageContent" runat="server">
<asp:LoginView ID="UmbracoLoginView" runat="server">
	<AnonymousTemplate>
	<div class="mainlogin">
		<div class="loginbox">
			<div class="login">
				<asp:Login ID="Login1" runat="server"
				RememberMeSet="True"
				DestinationPageUrl="/forside.aspx" 
                OnLoginError="OnLoginError"
				>
					<LoginButtonStyle Width="125"/>
					<LayoutTemplate>
						
						<asp:TextBox Width="186" id="UserName" runat="server" CssClass="usernameinput">Brugernavn</asp:TextBox>
						<asp:requiredfieldvalidator id="UserNameRequired" runat="server" ControlToValidate="UserName" Text="*" errormessage="Indtast brugernavn"></asp:requiredfieldvalidator>
						
						<asp:TextBox Width="186" id="Password" runat="server" CssClass="passwordinput">Adgangskode</asp:TextBox>
						<asp:requiredfieldvalidator id="PasswordRequired" runat="server" ControlToValidate="Password" Text="*" errormessage="Indtast adgangskode"></asp:requiredfieldvalidator>
						
						<!--<br>&nbsp;<asp:Checkbox id="RememberMe" runat="server" Text="Husk mig"></asp:Checkbox>-->
						<br>
						
						<asp:button id="Login" CommandName="Login" runat="server" BorderWidth="0" CssClass="loginbutton"></asp:button>
						
					</LayoutTemplate>
				</asp:Login>
			</div>
		</div>
	</div>
	</AnonymousTemplate>
	<LoggedInTemplate>
		<div>
			<div id="content-header-noleftmenu">
				<div class="overskrift">
					Du er logget på som:
				</div>
				<div class="suboverskrift">
					 <asp:LoginName ID="LoginName1" runat="server" />
				</div>
			</div>
		</div>
		<div>
			<div class="annonce-container-noleftmenu">
				<div class="info_content-noleftmenu">
					<p>Siden du forsøger at få vist er beskyttet. Log på som bruger der har adgang til den ønskede side.</p>
					<p>Tryk på "Log af" for at logge af.</p>
				</div>
			</div>
			<div class="rightbar-container">
				<div id="frontpage-right-pane">
				   <div class="frontpage-teaser-box">
						<div>
							<img src="../data/assets/images/problem.png" />
						</div>
					</div>
				</div>
			</div>
		</div>
    </LoggedInTemplate>
</asp:LoginView>

</asp:Content>

I get the follwing errormassage:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'Login1' does not exist in the current context

Source Error:

Line 5:  void OnLoginError(object sender, EventArgs e)
Line 6:  {
Line 7:      Login1.HelpPageText = "Help with logging in...";
Line 8:      Login1.PasswordRecoveryText = "Forgot your password?";
Line 9:  }

I can't figure out what is wrong since my asp:Login ID is Login1.

Would appreciate a helping hand.
/Hammond Hansen

Solved it myself. Feel soooo stupid.
All I did was create a litteral with Failuretext as ID and added Failuretext="Errortext goes here" to my <asp:Login> declaration.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.