Friday, October 24, 2008

ASP.NET (C#) unable to ENTER to submit form

The best way to solve this is to do the following

1. Create a login function. i.e.
protected void login() {
// get database connection
// get variables from form
// check if correct, set session variable, redirect
// else, display error, return to form
}

2. In page load, use the following code:
If (Page.IsPostBack()) {
login();
}

Viola! Weird bug in ASP.NET i read. But yah, Page.IsPostBack fixes it all.

No comments: