Question

I am using C# ASP.Net to create a simple website. I am using a master page (MasterPage.master).

I am trying to set up an asp:Login control, and intercept the LoginError event, so that I can change the FailureText to reflect the nature of the login failure.

On the Login.aspx.cs page, I have a fn that attempts to respond the LoginError event

protected void Login1_LoginError(object sender, EventArgs e) { // Reset the Login1.FailureText string according to what has gone wrong }

This is not firing.

If I am using a master page, is the name of the control mangled? I have tried using "ContentPlaceHolder1_Login1_LoginError" as the response function, and tons of other variants.

I have tried trapping other events such as Login1_Authenticate etc, but they are not working, so I assume I am not using the controls' correct name. It should work and it's driving me nuts!

Thanks in advance for any help with this.

Était-ce utile?

La solution

You didn't show how you defined your Login control in Login1.aspx so I am assuming you didn't set the OnLoginError event.

It should be:

<asp:Login ID="Login1" runat="server" OnLoginError="Login1_LoginError">
</asp:Login>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top