how to insert c# data into sql server in asp.net website? : The Code in aspx file.
    protected void Page_Load(object sender, EventArgs e)
    {
        con.ConnectionString = "server=localhost;user id=root;password=Welcome@123database=login;";
            }
    protected void Button2_Click(object sender, EventArgs e)
    {    
        try
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("insert into user(userid,username,password) values('" + txtuserid.Text + "','" + txtusername.Text + "','" + txtpassword.Text + "')", con);
            cmd.Parameters.AddWithValue("@user_id", txtuserid.Text);
            cmd.Parameters.AddWithValue("@username", txtusername.Text);
            cmd.Parameters.AddWithValue("@password", txtpassword.Text);
            cmd.ExecuteNonQuery();
            Response.Write("<script>alert('User Added Successfully')</Script>");       
            con.Close();
           }
        catch (Exception ex)
        {
            Response.Write("<script>alert('User Registration was unsuccessfull')</Script>");
        }
    }
}
