您的位置:首页 > 其它

xml保存图片和读取图片

2012-06-07 00:48 369 查看
以下是我做过的一个利用xml保存图片和读取图片的小项目,项目名称:WebForm_Question2:
主页面:index.aspx
图片列表:ImageList.aspx
显示图片:ImagDisplay.aspx
xml文件:ImageList.xml

<?xml version="1.0" encoding="utf-8"?>
<imagelist>
<image>
<imageID>1</imageID>
<imagepath>C:\Documents and Settings\Administrator\My Documents\image\新建文件夹\it1.jpg</imagepath>
<imageinfo>图片1</imageinfo>
<imagesize>3563</imagesize>    <imagedata>/9j/4AAQSkZJRgABAQEASABIAAD//gApSW50ZWwoUikgSlBFRyBMaWJyYXJ5LCB2ZXJzaW9uIDEsNSw0LDM2/9sAQwAIBgYHBgUIBwcHCQkICgwUDQwLCwwZEhMPFB0aHx4dGhwcICQuJyAiLCMcHCg3KSwwMTQ0NB8nOT04MjwuMzQy/9sAQwEJCQkMCwwYDQ0YMiEcITIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy/8AAEQgAWgB4AwEiAAIRAQMRAf/EABsAAAIDAQEBAAAAAAAAAAAAAAQFAgMGAAEH/8QAPhAAAgEDAwIEBAMDCQkAAAAAAQIDAAQRBRIhMUEGEyJRYXGBoRQyQiOR0QcVUmKCscHh8CQlMzRDcpKi8f/EABkBAAIDAQAAAAAAAAAAAAAAAAECAwQFAP/EACgRAAICAQQBAwMFAAAAAAAAAAECABEDBBIhQVEFEzFh0fAicbHh8f/aAAwDAQACEQMRAD8A0emaFdafp8EUd/JBMEBkSNVMYbuACOlMUOuQgENY3S+zK0TH6jIpoqggZGasCg4HTFZ7MSbMlEWrqtzF/wA1o10oHVoGWUfbn7UTF4j0gtse5Nu5/TcIYz96LCEGpPGsilXVXHswyKWzGqXRTQ3C7oZY5VPdGBqYBGaTy+H9LlbcLKON/wCnCTGf3qRXi6TdQc2esXkYHRZtsy/fn711zqjkrXhXOTSU3ms2e4S/grsKobKq8TEH94/hRJ1hdzgw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CF2SL1J3bucA+3bpQlzrEVwA0lorucs7EBQ3xx0pnM2k4z5V1NcEDKiI7QcVQsUTbjFo1y7HgFgFAH1NRe8klf1VSBwSR35/PEx+p2FvfTtcGNYgf0p0FU2+hFX9CLxzuwa2ixXBPp0tBzt3O44PyokaRqaKZCtpHgZyQXonOo6mc2rBNhZmodOuSuPKXaP1leDzRc/nWkETxwRhd4WRuyA9D8eadw6VeXbqk16VG3cu1B0prbaMtqD5s7zjr+05FKc9cASRfU84NzKWNpbatqMazxLOCQHcMwCjHtnFaqHw1pdvgx2cYx/VqtJxEJPLgRMflwOlXR6lLsy+0HOBxSMSxuVM2b3W3VGUUKQLiMYUdBXUrbUpQ4AC47/HOK6loyCSl8woRC22U8IfZu33oLTLSKESRvFGCpxwBjI4P3om4JWJmUkEAkEduKhZcwxk8kjJP1NcfiMIyt40QAhVyfYUXvoWL8q1d2qKNJnDHkVT+Ft92/ykBPXipj8lTX8tCdPBGgx6RVmAOQAKj3qX8a6GCXNisgZ4wA/UjsaEHmSbY0eXf0Kt0FOFqIADscDOKcGKYnn3WVwwhQAiPdkjPPtXNfXKrJxkqBgbffvTk9Kjge1NcWJ/xR87Dqpj/M52dfaqzdSBGcRoDvxt2flHvTtgNx4FVOBzRBgiiS5ZSf2CsuR6gvxrqZkcV1MDOn/9k=</imagedata>
</image>
<image>
<imageID>2</imageID>
<imagepath>C:\Documents and Settings\Administrator\My Documents\image\新建文件夹\re.jpg</imagepath>
<imageinfo>图片2</imageinfo>
<imagesize>4937</imagesize>
<imagedata>/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCABeAIwDASIAAhEBAxEB/8Q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ZOnW/nXjRyxpIpjG+OUksMnqM/Qdunc1rTvNp6w7T5sIXy9r/eZiRtGf06UAXliRZHkCgO+NxHfHSpKx5Jb43M8aXEe9EVhGijK59c9fxK5xUdlqccFv5colzvZgw+YMCSeuffB9waAGSxQHVLi2DsjSqJTtPG7vx3P3TxyMnmqjW93b6sbh7l2tkUqTAfnTpncGzuGef4iO1dBc2FrfKDNEGI6N0I/EVQl0BZI/Ja8uGhYrvjkIfKgg7ckZxxQBQ1j7HNAb2HyJjGFkLJKCSRgKNuQDn37cYNdBZz/a7KC427fNQPj0yKZPYW80yTMm2ZOFkThgPTPpUdnaSW085ExeCTDKrfeVu/PcHj8c9c0AVJUuXmMEyw7n3MjEnD4AH547UyCC7im8mEojeXv55KZyBn1P+HpWxJCJJYmPWNiw/EEf1pqwbbt7gN99FRlx6E4P6mgCftWPdaHayv5rALg7vkhTOfXIGa2KrzI0+YllaMd9qgk/nn+VAGJaIjzzW8TSRwxphWjcpGT/AHCMnB+mKz4IJo75pUglWON8xeRIuCB94ZPzHjGecZ6V0v8AZVrHHtRNrH+Pqf1qtHpEUCRi0d423DLE5JGMnHYH6Dt6UAUL8aTHENrpNLKodTLKxV8988jPpmm6RHLDEkytLJHsCKQ5AYAtjpkE4IHbpVq00BbZi8otnk7SrCAxHfI6ela1vbJAWYKoZjyVGM/WgCSGUTRh1yM9jTmRWIJUHHqKUAAYAwKWgChpdqLayijZMOpbkjnqf6Yqr4iKDT1LmUfvkAaI4ZcnBOe3Hc8Vs1U1CAXNpJEzMoyGJU4J2kEjPvjFAGJEkL3E0rWQUmIbGeViXz90A+pOcnHGO4rS0i3WPTk8+NGlYkscDHXAx7YApllZ28saXUkQLSAuBk4CjOByeevTp+QrXoA//9k=</imagedata>
</image>
</imagelist>


1.:index.aspx页面

<%@ Page language="c#" Codebehind="index.aspx.cs" AutoEventWireup="false" Inherits="WebForm_Question2.index" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>index</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 100; LEFT: 112px; WIDTH: 744px; POSITION: absolute; TOP: 48px; HEIGHT: 324px"
cellSpacing="1" cellPadding="1" width="744" border="1">
<TR>
<TD style="HEIGHT: 32px" colspan="2" align="center"><FONT face="宋体">
<asp:Label id="Label1" runat="server" Width="80px" ForeColor="#000040" Font-Bold="True" Font-Size="Larger">主页面</asp:Label></FONT></TD>
</TR>
<TR>
<TD style="WIDTH: 70px; HEIGHT: 32px">读取图片</TD>
<TD style="HEIGHT: 32px"><INPUT id="upImage" style="WIDTH: 328px; HEIGHT: 22px" type="file" size="35" name="File1"
runat="server">
<asp:Button id="btnUp_img" runat="server" Text="显示图片信息"></asp:Button></TD>
</TR>
<TR>
<TD style="WIDTH: 70px; HEIGHT: 20px">图片显示</TD>
<TD style="HEIGHT: 20px">
<asp:Image id="ImageSmall" runat="server"></asp:Image></TD>
</TR>
<TR>
<TD style="WIDTH: 70px; HEIGHT: 16px">图片路径</TD>
<TD style="HEIGHT: 16px">
<asp:Label id="Lab_imgpath" runat="server"></asp:Label></TD>
</TR>
<TR>
<TD style="WIDTH: 70px; HEIGHT: 5px">图片大小</TD>
<TD style="HEIGHT: 5px">
<asp:Label id="Lab_size" runat="server"></asp:Label></TD>
</TR>
<TR>
<TD style="WIDTH: 70px">图片说明</TD>
<TD>
<asp:TextBox id="Txt_imginfo" runat="server" TextMode="MultiLine" Width="645px" Height="144px"></asp:TextBox></TD>
</TR>
<TR>
<TD style="WIDTH: 70px"></TD>
<TD>
<asp:Button id="Btn_Add" runat="server" Text="添加图片信息到XML文件"></asp:Button>
<asp:Label id="Lab_message" runat="server" ForeColor="Red" Font-Bold="True"></asp:Label></TD>
</TR>
<TR>
<TD style="WIDTH: 70px"></TD>
<TD>
<asp:HyperLink id="HyperLink2" runat="server" NavigateUrl="ImageList.aspx">图片列表</asp:HyperLink><FONT face="宋体">
</FONT>
<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl="ImageList.xml">查看XMl文件</asp:HyperLink></TD>
</TR>
</TABLE>

</form>
</body>
</HTML>


2.index.aspx.cs页面

View Code

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;

namespace WebForm_Question2
{
/// <summary>
/// ImageList 的摘要说明。
/// </summary>
public class ImageList : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.HyperLink HyperLink2;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
protected System.Web.UI.WebControls.DataGrid DG_ImageList;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
ViewState["SortField"] = "imagesize"; //默认排序字段
BindDG();
}
}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DG_ImageList.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DG_ImageList_PageIndexChanged);
this.DG_ImageList.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DG_ImageList_ItemDataBound);
this.DG_ImageList.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.DataGrid_Sort);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
#region 将ImageList.xml文件绑定DataGrid中
private void BindDG()
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("ImageList.xml"));

DataView dv = (DataView)ds.Tables[0].DefaultView;

//设置排序的表达式
dv.Sort = SortField;
if (!SortAscending)
{
//定义默认的排序表达式
dv.Sort += " DESC";
}

this.DG_ImageList.DataSource = ds.Tables[0];
this.DG_ImageList.DataBind();
}
#endregion
#region 排序事件处理程序
public void DataGrid_Sort(Object sender,DataGridSortCommandEventArgs e)
{
//对DataGrid排序
this.DG_ImageList.CurrentPageIndex = 0;
SortField = e.SortExpression;

BindDG(); //重新绑定数据
}
string SortField
{
get
{
object obj = ViewState["SortField"];
if (obj == null)
{
return String.Empty;
}
return (string)obj;
}

set
{
if (value == SortField)
{
SortAscending = !SortAscending;
}
ViewState["SortField"] = value;
}
}

//排序方式
bool SortAscending
{
get
{
object obj = ViewState["SortAscending"];
if (obj == null)
{
return true;
}
return (bool)obj;
}
set
{
ViewState["SortAscending"] = value;
}
}

#endregion
#region DataGrid分页事件
private void DG_ImageList_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
this.DG_ImageList.CurrentPageIndex = e.NewPageIndex;
BindDG();

}
#endregion
#region 鼠标经过事件
private void DG_ImageList_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) |  (e.Item.ItemType == ListItemType.AlternatingItem) )
{
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#E4EDF9'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'");
}
}
#endregion
}
}


  

原文出处:当当网李燕平 

/article/4780292.html

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐