need help with create Login Box User Control with Validator and Event delegate

liunx

Guest
Hi, i made myself a User control: LoginBox.ascx
Given:
*it has 5 Web Controls: 2 labels, 2 textbox, (usrname, pw) 1 link (forget pw) and a submit button.
*it has 3 Validators: 2 RequiredFieldValidator, 1 RegularExpressionValidator
*it has 2 delegate events, so when it pass back to Default.aspx, Default will know if login was successful or not.

public event EventHandler LoginFailed;
public event LoginAuthenticatedEventHandler LoginAuthenticated;
public delegate void LoginAuthenticatedEventHandler(object sender, LoginAuthenticatedEventArgs e);

public class LoginAuthenticatedEventArgs : EventArgs
{
public int userID;
}//end class LoginAuthenticatedEventArgs

Problem:
1) looks like delegate call needs to take place under Page_Load method, and can't take place at cmd_Click method, otherwise LoginFailed and LoginAuthenticated will receive NullPointerException

2)if i put my delegate calls at Page_Load, then I can't put my Validator code under Page_Load or cmd_Click.

3)when put Validator code under Page_Load, asp.net complains
Page.IsValid cannot be called before validation has taken place

4)when put Validator code AFTER if(!this.IsPostBack), i can see the page when it first load, but once i click submit (when valid all my fields) the same asp.net complain as above come back again.

5)when move delegate event calls to cmd_click, validator works fine, now but now both LoginFailed and LoginAuthenticated get NullPointerException under my Try/Catch block....

please advise how to combine validor and LoginAuthenticated event with User Control.

TIA
 
Back
Top