Click here to Skip to main content
15,924,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI all

i am trying to create a login page...
after checking in database about the login user(if the user is valid), i want to navigate to other page,..so i used the following code:
C#
protected void imgb_login_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            lb_error.Text = "";
            int flag = 0;
            str = "SELECT * FROM [user]";
            c.cmd = new System.Data.SqlClient.SqlCommand(str, c.connect());
            //c.dr = c.cmd.ExecuteReader();
            c.da = new System.Data.SqlClient.SqlDataAdapter(str, c.connect());
            c.da.Fill(c.ds);
            c.dt = c.ds.Tables[0];
            maxrecord = c.dt.Rows.Count;
            string email = "", pwd = "";
            string tbemailvalue = tb_email.Text;
            string tbpwdvalue = tb_pwd.Text;

            for(int i = 0; i < c.dt.Rows.Count; i++)
            {
                email = c.dt.Rows[i].ItemArray[4].ToString();
                pwd = c.dt.Rows[i].ItemArray[5].ToString();
                if ((tb_email.Text == email) && (tb_pwd.Text == pwd))
                {
                    flag = 1;

                    Session["Ufname"] = c.dt.Rows[i].ItemArray[2].ToString();
                    break;
                }
            }


            tb_email.Text = "";
            tb_pwd.Text = "";
            if (flag == 1)
            {
                //Session["Ufname"] = txbemail.Text;
               // Response.Redirect("Default.aspx");
                // Response.Write("authorised user.");
                imgb_login.PostBackUrl = "~/Default.aspx";
            }
            else
            {
                //Label6.Text = "Invalid User,<br/>Check Your Email Id and Password.";
                lb_error.Text ="Not an authorised user.";
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }



and now my problem is post backurl is not working in single click...
its working only in double click..

can any one plz help mee


thanks in advance....
Posted

1 solution

Change code like this at client side

VB
<asp:Button
  ID="Button1"
  PostBackUrl="~/TargetPage.aspx"
  runat="server"
  Text="Submit" />


or

use
Response.Redirect("~/Default.aspx"
);
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900