Kod Akademi

Kod Akademi

Share

30/05/2012

ASP.NET Silme

protected void btnsil_Click(object sender, EventArgs e)
{
SqlConnection bag = new SqlConnection();
bag.ConnectionString = "Data Source=(local);Initial Catalog=candeneme;Integrated Security=True";
SqlCommand sil = new SqlCommand();
sil.CommandText = "delete from carikart where Ckod=";
sil.Parameters.AddWithValue("", TextBox4.Text);
sil.Connection = bag;
bag.Open();
int sonuc = sil.ExecuteNonQuery();
if (sonuc > 0)
{
Label1.Text = "Kayıt Silindi...";
TextBox4.Text = "";
}
else
{
Label1.Text = "Hata oluştu...";
}
bag.Close();
sil.Dispose();
Response.Redirect("default.aspx");
}
}

28/05/2012

"PAYLAŞMAK GÜZELDİR. PAYLAŞMAK KENDİNE OLAN GÜVENDİR. BİLGİ PAYLAŞIMI ÜLKEMİZİN GELECEĞİDİR. ÜLKEMİZİN GELECEĞİ İÇİN PAYLAŞALIM."

Checkbox

Örnek
Dropdownlist ilk seçenek seçildiğinde "CheckBox" lart seçli hala gelecek,
ikinci seçenek seçlidiğinde ise "CheckBox" lardan biri seçili diğeri pasif hale gelecektir.

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (Convert.ToInt32(DropDownList1.SelectedItem.Value) == 0)
{
CheckBox1.Checked = true;
CheckBox2.Checked = true;
}
else if(Convert.ToInt32(DropDownList1.SelectedItem.Value)==1)
{
CheckBox1.Checked = true;
CheckBox2.Checked = false;
}
}

RadioButton

RadioButton kontrolü

protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButton1.Checked == true)
{
Literal1.Text = "Seçtiğiniz Cinsiyet " + RadioButton1.Text.ToString();
}
else if (RadioButton2.Checked == true)
{
Literal1.Text="Seçtiğiniz Cinsiyet "+RadioButton2.Text.ToString();
}
RadioButton1.Checked = false;
RadioButton2.Checked = false;

}

FileUpload
Bir dosya sunucuya yüklemek için aşağıdaki kot kullanılır.

protected void Button2_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string yukle = FileUpload1.FileName;
Literal1.Text = yukle;
FileUpload1.SaveAs(Server.MapPath(yukle));
Response.Write("Yüklendi");
}
else
{
Response.Write("Yüüklenmedi...");


}
}

26/05/2012

Başka güzel bir örnek

C # – ASP.NET Random Sınıfı ile Rastgele Karşılama Cümlesi

protected void Page_Load(object sender, EventArgs e)
{
string[] mesaj = { "Selam", "Hoş Geldiniz", "Bizi Takip ediniz." };
Random rnd = new Random();
Response.Write(mesaj[rnd.Next(0, mesaj.Count())]);

}

Bilgi paylaştıkça büyür.
Yazan:happyman

Want your school to be the top-listed School/college in Adana?
Click here to claim your Sponsored Listing.

Category

Address


Adana
01130