ÄúĿǰÉÐδµÇ½£¬ÇëÑ¡Ôñ¡¾µÇ½¡¿»ò¡¾×¢²á¡¿
Ê×Ò³->ȫվ´úÂë->XMLͬѧ¼ϵͳԴÂ루±ÏÒµÉè¼Æ£©>>reg.aspx.cs>>´úÂëÔÚÏ߲鿴
ÎÂܰÌáʾ£º´úÂëÔÚÏßä¯ÀÀ¹¦ÄÜÖ»ÄÜ×öΪԴÂëä¯ÀÀ²Î¿¼£¬²»ÄÜչʾÏîÄ¿µÄÈ«²¿£¬Èç¹ûÏë¸ü½øÒ»²½Á˽â¸Ã´úÂëÇëÏÂÔØ£ºXMLͬѧ¼ϵͳԴÂ루±ÏÒµÉè¼Æ£©


µ±Ç°Îļþ·¾¶£ºXMLClassBooks/reg.aspx.cs ÎļþÀàÐÍ
ÆÕͨÊÓͼ
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.IO; 12 13using xmlOp; //ÒýÈëXmlOpÀàµÄÃüÃû¿Õ¼ä 14 15public partial class Reg : System.Web.UI.Page 16{ 17 string xmlFile = ConfigurationManager.AppSettings["xmlFile"]; //¶Á³öÅäÖÃÎļþµÄXmlÎļþ·¾¶ 18 Logic lg = new Logic(); //´´½¨LogicÀà¶ÔÏó 19 20 protected void Page_Load(object sender, EventArgs e) 21 { 22 if (!IsPostBack) 23 { 24 XmlOp op = new XmlOp(xmlFile); //´´½¨XmlOpÀà¶ÔÏó 25 if (op.NodeCount("//Root") == 0) //Èç¹ûÒ»¸öͬѧ³ÉÔ±¶¼Ã»ÓУ¬ÔòÈ¡ÏûÐÕÃûÑéÖ¤ 26 this.CustomValidator1.Enabled = false; 27 } 28 } 29 30 //Ìá½»×¢²áÐÅÏ¢ 31 protected void btnReg_Click(object sender, EventArgs e) 32 { 33 if (IsValid) //Èç¹ûͨ¹ýËùÓÐÑéÖ¤ 34 { 35 string _name = txtUserName.Text.Trim(); 36 string _nickName = txtNickName.Text.Trim(); 37 string _pwd = txtUserPwd.Text.Trim(); 38 string _sex = rbtnMan.Checked ? rbtnMan.Text : rbtnWoman.Text; //ÅжÏÐÔ±ð 39 string _birthday = txtBirthday.Text.Trim(); 40 string _email = txtEmail.Text.Trim(); 41 string _qq = txtQQ.Text.Trim(); 42 string _msn = txtMsn.Text.Trim(); 43 string _Tel = txtTel.Text.Trim(); 44 string _address = txtAddress.Text.Trim(); 45 string _work = txtWork.Text.Trim(); 46 string _homepage = txtHomePage.Text.Trim(); 47 string _photo = ""; 48 string _time = DateTime.Now.ToString(); 49 50 //ÉÏ´«Í¼Æ¬ 51 string _file = this.FileUpload1.FileName.ToString().ToLower(); 52 if (_file != "") 53 { 54 string _fileType = this.FileUpload1.PostedFile.ContentType; 55 if (_fileType.Substring(0, 5) == "image") //ÅжÏÊÇ·ñͼƬÎļþ 56 { 57 _photo = "images/" + _name + _file.Substring(_file.LastIndexOf(".")); 58 this.FileUpload1.SaveAs(Server.MapPath(_photo)); //±£´æÍ¼Æ¬ 59 } 60 else 61 { 62 lg.Msg("ͼƬ¸ñʽ²»¶Ô!"); 63 return; //ÖÕÖ¹Ö´ÐÐ 64 } 65 } 66 //½ÚµãÊý×é 67 string[] stu ={"Name", "NickName", "Pwd", "Sex", "Birthday", "Email", 68 "QQ", "Msn", "Tel", "Homepage", "Address", "Work", "Photo","Time" }; 69 //½ÚµãÖµÊý×é 70 string[] stuInfo ={_name, _nickName, _pwd, _sex, _birthday, _email, 71 _qq, _msn, _Tel, _homepage, _address, _work, _photo,_time }; 72 73 XmlOp op = new XmlOp(xmlFile); 74 //µ÷ÓÃXml²Ù×÷ÀàµÄInsertNode·½·¨£¬²åÈëеÄͬѧ³ÉÔ±¼Ç¼ 75 if (op.InsertNode("//Root", "Student", stu, stuInfo)) 76 { 77 op.InsertAttrib("//Root/Student[Name='"+ _name +"']","Admin","no"); 78 op.Save(xmlFile); //±£´æXmlÎĵµ 79 lg.Msg("¹§Ï²,³É¹¦ÒÑ×¢²á!"); 80 ClearTextBox(); //Çå¿ÕËùÓÐÎı¾¿ò 81 } 82 } 83 } 84 85 //ÑéÖ¤Ãû×ÖÊÇ·ñ´æÔÚ 86 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) 87 { 88 string _name = args.Value; //È¡µÃÒªÑéÖ¤µÄÎı¾¿òÖµ 89 XmlOp op = new XmlOp(xmlFile); 90 if (op.SelectNode("//Root/Student", 0, _name)) //ÅжÏÊÇ·ñ´æÔÚ 91 args.IsValid = false; 92 else 93 args.IsValid = true; 94 } 95 96 //ÖØÐ´°´Å¥Ê¼þ 97 protected void btnReset_Click(object sender, EventArgs e) 98 { 99 ClearTextBox(); //µ÷ÓÃÇå¿ÕÎı¾¿òº¯Êý 100 } 101 102 //Çå¿ÕÎı¾¿ò 103 private void ClearTextBox() 104 { 105 this.txtAddress.Text = ""; 106 this.txtBirthday.Text = ""; 107 this.txtEmail.Text = ""; 108 this.txtTel.Text = ""; 109 this.txtHomePage.Text = ""; 110 this.txtMsn.Text = ""; 111 this.txtNickName.Text = ""; 112 this.txtQQ.Text = ""; 113 this.txtUserName.Text = ""; 114 this.txtUserPwd.Text = ""; 115 this.txtUserPwd2.Text = ""; 116 this.txtWork.Text = ""; 117 } 118} 119
»¹Ã»ÓÐÕÒµ½ÄúÐÄÒǵÄÄÚÈÝ£¿ÇëÓÃ.netÔ´Âë´óËѲ¶
´úÂëÆ¬¶Ï ´ò°üÏÂÔØ¸ÃÏîÄ¿ÍêÕûÔ´Â룺XMLͬѧ¼ϵͳԴÂ루±ÏÒµÉè¼Æ£©

- ÔÚÏß¿¼ÊÔϵͳÍêÕû°æÔ´Âë(C#&..

- Cpush»áÔ±¹ÜÀíϵͳ2007Ô´´úÂë

- СºúÉÌÇéÍøV2.0

- ¼òµ¥Êý¾Ý²éѯÓ뱨±í´òӡϵͳԴÂë

- ÀËÂþÑ©»¡ÐíÔ¸Ê÷Ô´Âë

- ¼òµ¥µÄ²é¿±ÐÅÏ¢µ÷¶È¹ÜÀíϵͳ

- I-favourite2.0¶àÓû§²©¿Íϵ..

- PersonalBlogÔ´Âë

51Aspx.com °æÈ¨ËùÓÐ CopyRight © 2000-2008. ¾©ICP±¸06046876ºÅ