复制代码 代码如下: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 xn in xnl)     {         XmlElement xe=(XmlElement)xn;         if(xe.GetAttribute("name")=="发明")         {             //xe.RemoveAttribute("name");//删除name属性             xe.RemoveAll();//删除该节点的全部内容             break;         }     }     xmlDoc.Save(Server.MapPath("user.xml"));//保存 } private void showIt() {     LoadXml();     XmlNode xn=xmlDoc.SelectSingleNode("user");     XmlNodeList xnl=xn.ChildNodes;     foreach(XmlNode xnf in xnl)     {         XmlElement xe=(XmlElement)xnf;         // Console.WriteLine(xe.GetAttribute("name"));//显示属性值         // Console.WriteLine(xe.GetAttribute("sex"));         // // XmlNodeList xnf1=xe.ChildNodes;         // foreach(XmlNode xn2 in xnf1) //         {             // Console.WriteLine(xn2.InnerText);             //显示子节点点文本     // }     } } Xml的样式: 复制代码 代码如下:<?xml version="1.0" encoding="gb2312"?

本文实例为大家介绍了ajax验证用户名和密码的具体代码,供大家参考,具体内容如下1.ajax主体部分     var xmlrequest;function createXMLHttpRequest(){ if(window.XMLHttpRequest){ xmlrequest=new XMLHttpRequest(); } else if(window.ActiveXObject){ try{ xmlrequest=new ActiveXObject("Msxm12.XMLHTTP"); } catch(e){ try{ xmlrequest=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){} } }}function login(){ createXMLHttpRequest(); var user = document.getElementById("yhm").value; var password = document.getElementById("mm").value; if(user==""||password==""){ alert("请输入用户名和密码!"); return false; } var url = "check.php?user="+user+"&password="+password; xmlrequest.open("POST",url,true); xmlrequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xmlrequest.onreadystatechange = function(){ if(xmlrequest.readyState == 4){ if(xmlrequest.status==200){ var msg = xmlrequest.responseText; if(msg=='1'){ alert('用户名或密码错误!'); user=""; password=""; return false; } else{ window.location.href="index1.html"; } } } } xmlrequest.send("user="+user+"&password="+password); }2.html代码     <input placeholder="用户名" autofocus="" type="text"name="username"> <input placeholder="密码" type="password" name="password"> <button id="dl" onclick="login()">登录</button>3.这里用的是sha1加密,把你的密码和数据库名称修改成你自己的即可     <?php$yhm1=$_POST['user']; $mm1=$_POST['password'];@ $dp=new mysqli('localhost','root','你的密码','你的数据库名称');$yhm2=sha1($yhm1);$mm2=sha1($mm1);$query="select * from zhuce where yhm='$yhm2' and mm='$mm2'";$result=$dp->query($query);$num=$result->num_rows;if(!$num){ echo "1";} $dp->close(); ?>以上就是本文的全部内容,希望对大家的学习有所帮助。

const是一个修饰常量的关键字,它限定一个变量不允许被改变。使用const在一定程度上可以提高程序的安全性和可靠性,它在程序设计中有着非常重要的作用,给开发人员带来非常方便的应用。下面我们来建一个控制台应用程序作测试:public class Test{ public readonly string name = "George"; public const string coname = "ABC Company LLC"; public Test(string name) { // readonly 修饰的变量能且只能在 Constructor(构造函数)中被改变 this.name = name; } public string _name { get { return name; } //不可以对readonly修饰的变量进行Set操作 //set //{ // name = value; //} }} class Program{ static void Main(string[] args) { Test obj = new Test("Test"); //readonly的变量不可以修改值,只能在 Constructor(构造函数)中被改变 //obj.name = "New Value"; Console.WriteLine(obj.name); //const 的变量直接通过对象访问,不需要实例化 Console.WriteLine(Test.coname); Console.Read(); }}以前一直以为 readonly 与 const 的作用是一样的,现在明白它们之间的区别了,不知道您是否也明白了呢?

复制代码 代码如下: <asp:CheckBoxList ID="DDLGroups" runat="server" RepeatLayout="Table" RepeatColumns="2" RepeatDirection="Horizontal" style="border-collapse:collapse; line-height:18px;margin-left:2px;"> </asp:CheckBoxList> 复制代码 代码如下: <style type="text/css"> #DDLGroups{border-collapse:collapse; line-height:18px} #DDLGroups td{width:300px; border:1px solid #F0F8FF;padding-left:5px} </style> 获取所选值: 复制代码 代码如下: //获取联系人组 $("#DDLGroups tbody tr td input:checkbox:

第一步,添加一个一般处理程序(Handler),本例是ImageHandler复制代码 代码如下:using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Net.Mime;using System.IO;using System.Drawing;using System.Drawing.Imaging;using System.Drawing.Drawing2D;/// <summary>/// Summary description for ImageHandler/// </summary>public class ImageHandler : IHttpHandler{    public ImageHandler()    {    }    public string GetContentType(String path)    {        switch (Path.GetExtension(path))        {            case ".bmp": return "Image/bmp";            case ".gif": return "Image/gif";            case ".jpg": return "Image/jpeg";            case ".png": return "Image/png";            default: break;        }        return String.Empty;    }    public ImageFormat GetImageFormat(String path)    {        switch (Path.GetExtension(path).ToLower())        {            case ".bmp": return ImageFormat.Bmp;            case ".gif": return ImageFormat.Gif;            case ".jpg": return ImageFormat.Jpeg;            case ".png": return ImageFormat.Png;            default: return null;        }    }    protected byte[] WatermarkImage(HttpContext context)    {        byte[] imageBytes = null;        if (File.Exists(context.Request.PhysicalPath))        {            // Normally you'd put this in a config file somewhere.            string watermark = "世复检测";            Image image = Image.FromFile(context.Request.PhysicalPath);            Graphics graphic;            if (image.PixelFormat != PixelFormat.Indexed && image.PixelFormat != PixelFormat.Format8bppIndexed && image.PixelFormat != PixelFormat.Format4bppIndexed && image.PixelFormat != PixelFormat.Format1bppIndexed)            {                // Graphic is not a Indexed (GIF) image                graphic = Graphics.FromImage(image);            }            else            {                /* Cannot create a graphics object from an indexed (GIF) image.                  * So we're going to copy the image into a new bitmap so                  * we can work with it. */                Bitmap indexedImage = new Bitmap(image);                graphic = Graphics.FromImage(indexedImage);                // Draw the contents of the original bitmap onto the new bitmap.                 graphic.DrawImage(image, 0, 0, image.Width, image.Height);                image = indexedImage;            }            graphic.SmoothingMode = SmoothingMode.AntiAlias & SmoothingMode.HighQuality;            Font myFont = new Font("Arial", 15);            SolidBrush brush = new SolidBrush(Color.FromArgb(255, Color.Red));            /* This gets the size of the graphic so we can determine              * the loop counts and placement of the watermarked text. */            SizeF textSize = graphic.MeasureString(watermark, myFont);            //// Write the text across the image.             //for (int y = 0; y < image.Height; y++)            //{            //    for (int x = 0; x < image.Width; x++)            //    {            //        PointF pointF = new PointF(x, y);            //        graphic.DrawString(watermark, myFont, brush, pointF);            //        x += Convert.ToInt32(textSize.Width);            //    }            //    y += Convert.ToInt32(textSize.Height);            //}            // Write the text at the right bottom of the image.             for (int y = image.Height-25; y < image.Height; y++)            {                for (int x = image.Width-100; x < image.Width; x++)                {                    PointF pointF = new PointF(x, y);                    graphic.DrawString(watermark, myFont, brush, pointF);                    x += Convert.ToInt32(textSize.Width);                }                y += Convert.ToInt32(textSize.Height);            }            using (MemoryStream memoryStream = new MemoryStream())            {                image.Save(memoryStream, GetImageFormat(context.Request.PhysicalPath));                imageBytes = memoryStream.ToArray();            }        }        return imageBytes;    }    #region IHttpHandler Members    public bool IsReusable    {        get { return false; }    }    public void ProcessRequest(HttpContext context)    {        context.Response.Clear();        context.Response.ContentType = GetContentType(context.Request.PhysicalPath);        byte[] imageBytes = WatermarkImage(context);        if (imageBytes != null)        {            context.Response.OutputStream.Write(imageBytes, 0, imageBytes.Length);        }        else        {            // No bytes = no image which equals NO FILE.                // Therefore send a 404 - not found response.             context.Response.StatusCode = 404;        }        context.Response.End();    }    #endregion}第二步,在web.config里添加如下代码:复制代码 代码如下:    <httpHandlers>      <!--<add verb="GET" type="ImageHandler" path="*.jpg,*.png,*.gif,

分类:腾博会手机版下载

时间:2016-05-22 07:13:16