In an apsx page there is a div (popup dialog) which contains a text of " error , please check in your login crendentials…" , By calling code below , the div will be displayed :
$('#error-dialog').fadeIn('normal');
So there is a C# method which check database table and return the login result as bool.I want to display popup dialog when Login failures… I mean I want to display that in the else statement. how can I done that ?
Markup used :(also there is a script attached to page ….)
<div id="login-wrapper">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="error-dialog">
<div id="icon">
</div>
<div id="messageText">
</div>
<a href="#" id="ok_button">
.....
C# Code :
protected void btnLogin_Click(object sender, EventArgs e)
{
UserController ucontoller = new UserController();
System.Threading.Thread.Sleep(1000);
if (ucontoller.Check(txtUsername.Text, txtPassword.Text))
{
if (txtUsername.Text.Contains("admin"))
{
Response.Redirect("~/Administrator.aspx?uname=" + txtUsername.Text);
}
else
{
Response.Redirect("~/user.aspx?uname=" + txtUsername.Text);
}
}
else
{
//display error popup....
}
}
Here is what I do – I’m not claiming it’s the best way to go, but it works for me. Using your button click event (assuming it’s posting back) you can add the following. Note, this is VB, so you’ll have to covert to C#.