net8:XML的读写操作【广告控件的XML文件实例】
2021-06-29 09:05
标签:can version 来源 sub tco int 发布 button style 原文发布时间为:2008-08-05 —— 来源于本人的百度文章 [由搬家工具导入] 【用了datalist控件,datalist控件自己学会,主要知道其他按钮COMMANDNAME属性应该改为edit,update,delete】 using System; using System.Xml; public partial class _Default : System.Web.UI.Page } protected void fill() Session["dst"]=ds; protected void Button1_Click(object sender, EventArgs e) } } Session["dst"] = ds; DataList1.EditItemIndex=-1; fill(); dr["ImageUrl"] = url.Text.ToString(); ds.Tables[0].Rows.Add(dr); ds.WriteXml(Server.MapPath("~/App_Data/ad.xml")); if (type == "image") ---------------------------------------------- ad.xml的内容: net8:XML的读写操作【广告控件的XML文件实例】 标签:can version 来源 sub tco int 发布 button style 原文地址:http://www.cnblogs.com/handboy/p/7141595.html
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.XPath;
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fill();
}
{
DataSet ds=new DataSet();
ds.ReadXml(Server.MapPath("~/App_Data/ad.xml"));
DataList1.DataSource=ds.Tables[0].DefaultView;
DataList1.DataBind();
}
{
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
DataList1.EditItemIndex = e.Item.ItemIndex;
fill();
}
protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
{
DataSet ds = (DataSet)Session["dst"];
ds.Tables[0].Rows[e.Item.ItemIndex]["ImageUrl"] = ((TextBox)e.Item.FindControl("TextBox2")).Text.ToString();
ds.Tables[0].Rows[e.Item.ItemIndex]["NavigateUrl"] = ((TextBox)e.Item.FindControl("TextBox5")).Text.ToString();
ds.Tables[0].Rows[e.Item.ItemIndex]["AlternateText"] = ((TextBox)e.Item.FindControl("TextBox1")).Text.ToString();
ds.Tables[0].Rows[e.Item.ItemIndex]["Keyword"] = ((TextBox)e.Item.FindControl("TextBox3")).Text.ToString();
ds.Tables[0].Rows[e.Item.ItemIndex]["Impressions"] = ((TextBox)e.Item.FindControl("TextBox4")).Text.ToString();
ds.WriteXml(Server.MapPath("~/App_Data/ad.xml"));
fill();
}
protected void DataList1_CancelCommand(object source, DataListCommandEventArgs e)
{
DataList1.EditItemIndex = -1;
fill();
}
protected void DataList1_DeleteCommand(object source, DataListCommandEventArgs e)
{
DataSet ds = (DataSet)Session["dst"];
ds.Tables[0].Rows.Remove(ds.Tables[0].Rows[e.Item.ItemIndex]);
Session["dst"] = ds;
ds.WriteXml(Server.MapPath("~/App_Data/ad.xml"));
}
protected void Button5_Click(object sender, EventArgs e)
{
DataSet ds = (DataSet)Session["dst"];
DataRow dr = ds.Tables[0].NewRow();
dr["NavigateUrl"] = ng.Text.ToString();
dr["AlternateText"] = na.Text.ToString();
dr["Keyword"] = kw.Text.ToString();
dr["Impressions"] = qz.Text.ToString();
Session["dst"] = ds;
fill();
DIV1.Visible = false;
Panel1.Visible = false;
}
protected void Button7_Click(object sender, EventArgs e)
{
Panel1.Visible = true;
na.Focus();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
DIV1.Visible = true;
ng.Focus();
}
protected void Button6_Click(object sender, EventArgs e)
{
string name = fu.FileName.ToString();
//int size = Convert.ToInt32(fu.PostedFile.ContentLength);
string type1 = fu.PostedFile.ContentType.ToString();
string type = type1.Substring(0, 5);
{
fu.PostedFile.SaveAs(Server.MapPath("~/img/") + name);
img.ImageUrl = Server.MapPath("~/img/") + name;
url.Text = Server.MapPath("~/img/") + name;
}
else
{
url.Text = "不是允许的类型";
}
}
protected void Button8_Click(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx");
}
}
洪川医药
百度
爱问
上一篇:页面之间传值的方法asp