Using Using Using Using Using Using Using Using Using Using Using Using Public Partial Class Protected Void Object If New
Using Using Using Using Using Using Using Using Using Using Using Using Public Partial Class Protected Void Object If New
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
public partial class Welcome : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DirectoryInfo d = new
DirectoryInfo(Server.MapPath("photo"));
FileInfo[] files = d.GetFiles();
for (int i = 0; i < files.Length; i++)
{
DropDownList1.Items.Add(files[i].Name);
ListBox1.Items.Add(files[i].Name);
}
}
}
protected void btn1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=(local);Initial
Catalog=company;Integrated Security=True;";
con.Open();
SqlCommand cmd = new SqlCommand("select * from login where
username=@name and password=@password",con);
cmd.Parameters.Add(new SqlParameter("@name",tb1.Text));
cmd.Parameters.Add(new SqlParameter("@password", tb2.Text));
SqlDataReader rd = cmd.ExecuteReader();
if (rd.Read())
{
status.Text = "you are a valid user!";
}
else
{
status.Text = "you are not a valid user!";
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Panel1.Visible = true; //
Response.Redirect("http://www.google.com");
}
protected void Button1_Click(object sender, EventArgs e)
{
File.WriteAllText(Server.MapPath("comment.txt"),TextBox1.Text);
Panel1.Visible = false;
}
protected void DropDownList1_SelectedIndexChanged(object sender,
EventArgs e)
{
Image1.ImageUrl =
Server.MapPath("photo/"+DropDownList1.SelectedValue);
}
protected void Button2_Click(object sender, EventArgs e)
{
FileUpload1.SaveAs(Server.MapPath("photo/"+FileUpload1.FileName));
DropDownList1.Items.Add(FileUpload1.FileName);
}
protected void Button3_Click(object sender, EventArgs e)
{
File.Delete(Server.MapPath("Photo/"+ListBox1.SelectedValue));
}
}