插入表情共用这个文件,用Request.QueryString["rif"]来判断提取什么表情。
文件名:EmoticonsGallery.aspx,记录一下,明天再看看
using System;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using AspNetForums.Components;
using Image = System.Drawing.Image;

namespace AspNetForums


{

/**//// <summary>
/// EmoticonGallery 的摘要说明。
/// </summary>
public class EmoticonsGallery : Page

{
protected System.Web.UI.WebControls.Image Image1;
protected Table EmoticonsTable;

private void Page_Load(object sender, EventArgs e)

{
StreamReader sr = new StreamReader(MapPath("~/Script/Emoticon.js"));
this.RegisterClientScriptBlock("EmoticonScript", sr.ReadToEnd());
sr.Close();

int ColumnCount = 10;
int index = 0;
// if (Request.QueryString["rif"] == null)
// return;

//string imagepath = Request.QueryString["rif"];

string imagepath ="Emoticons/JuPai";// Request.QueryString["rif"];

string path = MapPath(imagepath);
TableRow row = new TableRow();

if (File.Exists(path + "\\emoticons.xml"))

{
XmlDocument myxml = new XmlDocument();
myxml.Load(path + "\\emoticons.xml");
XmlNodeList nodes = myxml.SelectNodes("/emoticons/emoticon");
foreach (XmlNode node in nodes)

{
try

{
TableCell cell = new TableCell();
cell.BorderWidth = 1;

Image myimg = Image.FromFile(Server.MapPath("~/" + imagepath + "/") + node.Attributes["FileName"].Value);
string width = myimg.Width.ToString();
string height = myimg.Height.ToString();
string apppath = Globals.GetSiteUrls().Home; //Dottext.Framework.Util.Globals.GetAppUrl(Request);
string fileName = node.Attributes["FileName"].Value;
string toolTip = node.Attributes["ToolTip"].Value;
string fullWebFileName = apppath + imagepath + "/" + fileName;
string celltext = "<img border=0 src='" + fullWebFileName + "' onclick=\"returnImage('" + fullWebFileName + "','" + width + "','" + height + "','" + toolTip + "')\">";
cell.Text = celltext;
row.Cells.Add(cell);
index++;
if (index%ColumnCount == 0)

{
EmoticonsTable.Rows.Add(row);
row = new TableRow();
}
}
catch

{
}


}
}
else

{
DirectoryInfo dir = new DirectoryInfo(path);
foreach (FileInfo file in dir.GetFiles())

{
try

{
TableCell cell = new TableCell();
cell.BorderWidth = 1;

//System.Web.UI.WebControls.Image image=new System.Web.UI.WebControls.Image();
//image.ImageUrl=imagepath+"/"+file.Name;
Image myimg = Image.FromFile(file.FullName);
string width = myimg.Width.ToString();
string height = myimg.Height.ToString();
string apppath = Globals.GetSiteUrls().Home; //Dottext.Framework.Util.Globals.GetAppUrl(Request);
string celltext = "<div onclick=\"returnImage('" + apppath + imagepath + "/" + file.Name + "','" + width + "','" + height + "','" + file.Name + "')\">";
celltext += "<img src='" + imagepath + "/" + file.Name + "' alt='" + file.Name + "'>";
celltext += "</div>";
cell.Text = celltext;
//image.Attributes.Add("ondblclick","returnImage('"+image.ImageUrl+"','"+width+"','"+height+"')");
//cell.Controls.Add(image);
row.Cells.Add(cell);
index++;
if (index%ColumnCount == 0)

{
EmoticonsTable.Rows.Add(row);
row = new TableRow();
}
}
catch

{
}
}
}


//Response.Write(MapPath(folder));
Response.Expires = -1;
}


Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码

protected override
void OnInit(EventArgs e)

{
InitializeComponent();
base.OnInit(e);
}

private
void InitializeComponent()

{
this.Load +=
new
EventHandler(this.Page_Load);

}

#endregion
}
}