欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP.NET用戶(hù)注冊(cè)實(shí)戰(zhàn)(第11節(jié))

 更新時(shí)間:2022年04月27日 14:53:27   投稿:lijiao  
這篇文章主要介紹了ASP.NET用戶(hù)注冊(cè)實(shí)戰(zhàn),鞏固前10小節(jié)所學(xué)的全部知識(shí),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

在我們第四小節(jié)---ASP.NET實(shí)現(xiàn)用戶(hù)注冊(cè)和驗(yàn)證功能當(dāng)中,已經(jīng)學(xué)習(xí)了ASP.NET驗(yàn)證控件的作用和使用方法,所以相對(duì)來(lái)說(shuō)這節(jié)就比較輕松。

學(xué)習(xí)內(nèi)容:

步驟一 添加新項(xiàng),創(chuàng)建Web窗體并將其命名為“zhuce.aspx”
步驟二 布局頁(yè)面,創(chuàng)建6行2列的表格

步驟三  在zhucechuli.cs頁(yè)面中編寫(xiě)代碼如下:

public class zhucechuli
 { public zhucechuli()
  {
  }
  private SqlConnection conn;
   public static void addzhuce(zhuce zhuce1)
   {using (SqlConnection cn = dbconn.GetConnection())
   { cn.Open();
    SqlCommand cm = new SqlCommand();
    cm.Connection = cn;
    string sql = "insert zhuce(yhm,yhpwd,sex,hobby) values(@q,@w,@e,@r)";
    cm.CommandText = sql;
    cm.Parameters.AddWithValue("@q", zhuce1.Yhm);
    cm.Parameters.AddWithValue("@w", zhuce1.Yhpwd);
    cm.Parameters.AddWithValue("@e", zhuce1.Sex);
    cm.Parameters.AddWithValue("@r", zhuce1.Hobby);
    cm.ExecuteNonQuery();
   }
 }
}

步驟四 在實(shí)體類(lèi)文件夾下添加zhuce類(lèi)。在頁(yè)面中編寫(xiě)代碼如下:

namespace shiti
{
 /// <summary>
 ///zhuce 的摘要說(shuō)明
 /// </summary>
 public class zhuce
 { public zhuce()
  {
   }
  protected int id;
  public int ID
  {
   get { return id; }
   set { id = value; }
  }
  protected string yhm;
  public string Yhm
  {
   get { return yhm; }
   set { yhm = value; }
  }
  protected string yhpwd;
  public string Yhpwd
  {
   get { return yhpwd; }
   set { yhpwd = value; }
  }
 protected string sex;
  public string Sex
  {
   get { return sex; }
   set { sex = value; }
  }
protected string hobby;
  public string Hobby
  {
   get { return hobby; }
   set { hobby= value; }
  }
 }
}

步驟五 打開(kāi)zhuce.aspx設(shè)計(jì)頁(yè)面,雙擊Button1按鈕,編寫(xiě)代碼:

protected void Button1_Click(object sender, EventArgs e)
 {
  zhuce zhuce1 = null;
  zhuce1 = new zhuce();
  zhuce1.Yhm = TextBox1.Text.ToString().Trim();
  zhuce1.Yhpwd = TextBox2.Text.ToString().Trim();
  zhuce1.Sex = DropDownList1.SelectedValue.ToString().Trim();
  zhuce1.Hobby = DropDownList2.SelectedValue.ToString().Trim();
  zhucechuli.addzhuce(zhuce1); 
}

在這里補(bǔ)充一點(diǎn)內(nèi)容,因?yàn)檫@是在學(xué)習(xí)ASP.NET,所以數(shù)據(jù)庫(kù)內(nèi)容就沒(méi)有涉及到,下面就是我在學(xué)習(xí)ASP.NET時(shí)配置數(shù)據(jù)庫(kù)的部分內(nèi)容:

如果大家想了解更多關(guān)于數(shù)據(jù)庫(kù)這方面的內(nèi)容,就去網(wǎng)站關(guān)注數(shù)據(jù)庫(kù)欄目,內(nèi)容也很豐富的。

運(yùn)行效果圖:

總結(jié)

通過(guò)本節(jié)的學(xué)習(xí),實(shí)現(xiàn)了用戶(hù)的注冊(cè),進(jìn)一步完善了之前所學(xué)習(xí)的內(nèi)容,實(shí)現(xiàn)了前臺(tái)與數(shù)據(jù)庫(kù)后臺(tái)的連接,小編整理的ASP.NET的11個(gè)學(xué)習(xí)小結(jié),都是自己親自操作過(guò)并記錄下來(lái)的學(xué)習(xí)筆記,可能有些地方不大細(xì)致,表述的不夠準(zhǔn)確,希望大家理解。

相關(guān)文章

最新評(píng)論