asp.net ¶ÔxmlÎļþµÄ¶Áд,Ìí¼Ó,ÐÞ¸Ä,ɾ³ý²Ù×÷
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
private XmlDocument xmlDoc;
//load xml file
private void LoadXml()
{
xmlDoc=new XmlDocument();
xmlDoc.Load(Server.MapPath("User.xml"));
}
//Ìí¼Ó½Úµã
private void AddElement()
{
LoadXml();
XmlNode xmldocSelect=xmlDoc.SelectSingleNode("user");
XmlElement el=xmlDoc.CreateElement("person"); //Ìí¼Óperson½Úµã
el.SetAttribute("name","·çÔÆ"); //Ìí¼Óperson½ÚµãµÄÊôÐÔ"name"
el.SetAttribute("sex","Å®"); //Ìí¼Óperson½ÚµãµÄÊôÐÔ "sex"
el.SetAttribute("age","25"); //Ìí¼Óperson½ÚµãµÄÊôÐÔ "age"
XmlElement xesub1=xmlDoc.CreateElement("pass"); //Ìí¼Óperson½ÚµãµÄÀïµÄ½Úµã
xesub1.InnerText="123";//ÉèÖÃÎı¾½Úµã
el.AppendChild(xesub1);
XmlElement xesub2=xmlDoc.CreateElement("Address");
xesub2.InnerText="À¥Ã÷";//ÉèÖÃÎı¾½Úµã
el.AppendChild(xesub2);
xmldocSelect.AppendChild(el);
xmlDoc.Save(Server.MapPath("user.xml"));
}
//Ð޸Ľڵã
private void UpdateElement()
{
LoadXml();
XmlNodeList nodeList=xmlDoc.SelectSingleNode("user").ChildNodes;//»ñÈ¡bookstore½ÚµãµÄËùÓÐ×Ó½Úµã
foreach(XmlNode xn in nodeList)//±éÀúËùÓÐ×Ó½Úµã
{
XmlElement xe=(XmlElement)xn;//½«×Ó½ÚµãÀàÐÍת»»ÎªXmlElementÀàÐÍ
if(xe.GetAttribute("name")=="·çÔÆ")//Èç¹ûnameÊôÐÔֵΪ“·çÔÆ”
{
xe.SetAttribute("name","·¢Ã÷");
//Èç¹ûÏÂÃæÓÐ×Ó½ÚµãÔÚÏÂ×ß
XmlNodeList nls=xe.ChildNodes;//¼ÌÐø»ñÈ¡xe×Ó½ÚµãµÄËùÓÐ×Ó½Úµã
foreach(XmlNode xn1 in nls)//±éÀú
{
XmlElement xe2=(XmlElement)xn1;//ת»»ÀàÐÍ
if(xe2.Name=="pass")//Èç¹ûÕÒµ½
{
xe2.InnerText="66666";//ÔòÐÞ¸Ä
break;
}
}
break;
}
}
xmlDoc.Save(Server.MapPath("user.xml"));//±£´æ
}
//ɾ³ö½Úµã
private void deleteNode()
{
LoadXml();
XmlNodeList xnl=xmlDoc.SelectSingleNode("user").ChildNodes;
foreach(XmlNode
Ïà¹ØÎĵµ£º
1.Init£¨³õʼ»¯½×¶Î£©
2.LoadViewState£¨ÔØÈëÊÓͼ״̬£©
3.LoadPostData£¨´¦Àí»Ø·¢Êý¾Ý£©
public virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
ÅжÏÊÓÍ ......
aspÖÐSessionµÄ¹¤×÷ÔÀí£º
aspµÄSessionÊǾßÓнø³ÌÒÀÀµÐԵġ£ASP Session״̬´æÓÚIISµÄ½ø³ÌÖУ¬Ò²¾ÍÊÇinetinfo.exeÕâ¸ö³ÌÐò¡£ËùÒÔµ±inetinfo.exe½ø³Ì±ÀÀ£Ê±£¬ÕâЩÐÅÏ¢Ò²¾Í¶ªÊ§¡£ÁíÍ⣬ÖØÆð»òÕ߹رÕIIS·þÎñ¶¼»áÔì³ÉÐÅÏ¢µÄ¶ªÊ§¡£
asp.net SessionµÄʵÏÖ
asp.netµÄSessionÊÇ»ùÓÚHttpModule¼¼Êõ×öµÄ£¬HttpModule¿ÉÒÔÔÚÇëÇó±» ......
RepeaterÔÚǰ̨ʹÓñȽÏÁé»î×ÔÓÉ£¬µ«ÓÐÒ»¸öÎÊÌâ¾ÍÊÇRepeater²»Ö§³ÖÖ±½Ó·ÖÒ³£¬Õâ¸öºÜ¶àÈË¿´ÆðÀ´¾ÍÓе㲻ÏëÓÃÁË£¬µ«ÎÒÏë´ó¼Ò¶¼ÖªµÀGridView¿Ø¼þ»òDataGrid¿Ø¼þÔÚÆôÓÃ×Ô´ø·ÖÒ³µÄʱºòÆäʵЧÂÊÊǷdz£µÍµÄ£¬´óµÄ²»Ëµ£¬Ò»µ«µ½ÁË°ÙÍò¼¶Êý¾ÝÒԺ󣬾ͻá¸Ð¾õÊǶàôµÄÍ´¿àºÍÎÞÄÍÁË£¬ËùÒÔ¼´Ê¹ÊÇÓÃDataGrid(GridView)¿Ø¼þ£¬¸ßÊÖÃÇ»¹ÊÇÖ»»á ......
Ê×ÏÈ,ÎÒÃDZØÐëÁ˽âʲôÊÇwebservice.¾Í¸ÅÄîÉÏÀ´Ëµ,¿ÉÄܱȽϸ´ÔÓ,²»¹ýÎÒÃÇ¿ÉÒÔÓиöºê¹ÛµÄÁ˽â:webservice¾ÍÊǸö¶ÔÍâµÄ½Ó¿Ú,ÀïÃæÓÐ º¯Êý¿É¹©Íⲿ¿Í»§µ÷ÓÃ(×¢Òâ:ÀïÃæͬÑùÓпͻ§²»¿Éµ÷Óõĺ¯Êý).¼ÙÈôÎÒÃÇÊÇ·þÎñ¶Ë,ÎÒÃÇдºÃÁ˸öwebservice,È»ºó°ÑËü¸øÁË¿Í»§(ͬʱÎÒÃǸøÁËËû Ãǵ÷ÓùæÔò),¿Í»§¾Í¿ÉÒÔÔÚ´Ó·þÎñ¶Ë»ñÈ¡ÐÅϢʱ´¦ÓÚÒ»¸öÏ ......
ÒÔϾÑé×ܽá×Ô£¬²¢ÇÒ¾¹ýÑéÖ¤
1£¬²»²ÎÓëPOSTBACK»úÖƵĿؼþ£¬²»ÒªÓ÷þÎñÆ÷¿Ø¼þ£¬¾¡Á¿Óþ²Ì¬HTML±ê¼Ç
2£¬±àÒëʱʹÓÃRELEASEÅäÖÃ
3£¬ÕýʽͶÈëÓ¦ÓÃʱ£¬¼Ç׎«DEBUGÉèΪFALSE
4£¬SMARTNAVIGATE¼Ç×ÅÉèΪTRUE£¬Ëü¿ÉÒÔÈÃä¯ÀÀÕ߸оõµ½ÄãÐÔÄܵÄÌá¸ß
5£¬Èç¹û²»ÊDZØÐë±£³Ö¸üеÄÒ³Ã棬Çë¼Çס¼ÓÈëÉùÃ÷£¬Ëü¿ÉÒÔ´ó·ùÌá¸ßÐÔÄÜ
6£¬³ý ......