using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
readData();
}
}
//读取文本数据
public void readData()
{
string path = Server.MapPath("data.txt");
string[] xueli = File.ReadAllLines(path);
Image1.Width =Convert.ToInt32(xueli[0]);
Image2.Width = Convert.ToInt32(xueli[1]);
Image3.Width = Convert.ToInt32(xueli[2]);
Image4.Width = Convert.ToInt32(xueli[3]);
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
RadioButton rbtn = sender as RadioButton;
string id = rbtn.ID;
string path = Server.MapPath("data.txt");
string[] xueli = File.ReadAllLines(path);
switch (id)
{
case "RadioButton1":
Image1.Width = int.Parse(xueli[0]) + 5;
break;
case "RadioButton2":
Image2.Width = int.Parse(xueli[1]) + 5;
break;
case "RadioButton3":
Image3.Width = int.Parse(xueli[2]) + 5;
break;
case "RadioButton4":
Image4.Width = int.Parse(xueli[3]) + 5;
break;
}
xueli[0] = Image1.Width.ToString().Replace("px","");
xueli[1] = Image2.Width.ToString().Replace("px", "");
xueli[2] = Image3.Width.ToString().Replace("px", "");
xueli[3] = Image4.Width.ToString().Replace("px", "");
File.WriteAllLines(path, xueli);
readData();
}
}
本文出自: 一萧烟雨.NET家园, 原文地址: http://www.yixiaoyanyu.com/post/64.html