Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i got error from this project,any one can tell why is this..
error is System.web.UI.Page.SuspendLayout
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace WebRole1
{
    public partial class Userlogin : System.Web.UI.Page
    {
        SqlConnection con = new SqlConnection(@"Data Source=RAVI;Initial Catalog=multicloud;user id=sa;password=123456");
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            con.Open();
            SqlCommand comm = new SqlCommand("select * from users where username='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'", con);
            SqlDataReader drr = comm.ExecuteReader();
            if (drr.Read())
            {
                Label1.Visible = false;
                drr.Close();

                SqlCommand comm1 = new SqlCommand("select * from users where username='" + TextBox1.Text + "' and password='" + TextBox2.Text + "' and status='YES'", con);
                SqlDataReader drr1 = comm1.ExecuteReader();
                if (drr1.Read())
                {
                    Session["username"] = TextBox1.Text;
                    Response.Redirect("Home.aspx");

                }
                else
                {
                    Label2.Visible = true;
                    Label1.Visible = false;
                }
            }
            else
            {
                Label1.Visible = true;
                Label2.Visible = false;
            }
        }
    }
}
Posted
Updated 10-Mar-14 3:08am
v2
Comments
Maarten Kools 10-Mar-14 9:11am    
SuspendLayout[^] is a method inherited from Control.

What is the exact error you're getting?
Member 10642244 11-Mar-14 6:39am    
my error is - method 'System.Web.UI.Page.SuspendLayout' not found
Maarten Kools 11-Mar-14 8:24am    
It's a compiler error? And are you sure you get it from this file? Because there's no reference to that method at all.
Maarten Kools 10-Mar-14 9:17am    
If I may make a suggestion, the way you're executing your query to check the password and username match is extremely unsafe.

First of all your password is unencrypted. Never store your passwords unencrypted[^].
Secondly, this code is vulnerable to SQL Injection[^]. Always use parameterized queries, never accept unfiltered user entry as parameters for your query.
Member 10642244 11-Mar-14 6:43am    
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;


namespace WebRole1
{
public partial class Userlogin : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=ELCOT-PC\SQLEXPRESS;Initial Catalog=users;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{

}

protected void LinkButton1_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand comm = new SqlCommand("select * from users where username='" + textBox1.Text + "' and password='" + textBox2.Text + "'", con);
SqlDataReader drr = comm.ExecuteReader();
if (drr.Read())
{
label1.Visible = false;
drr.Close();

SqlCommand comm1 = new SqlCommand("select * from users where username='" + textBox1.Text + "' and password='" + textBox2.Text + "' and status='YES'", con);
SqlDataReader drr1 = comm1.ExecuteReader();
if (drr1.Read())
{
Session["username"] = textBox1.Text;
Response.Redirect("Home.aspx");

}
else
{
label2.Visible = true;
label1.Visible = false;
}
}
else
{
label1.Visible = true;
label2.Visible = false;
}
}
}
}

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