using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Dare.MS.DataProvider;
using System.Xml;
using System.Threading;
namespace DareExtServer
{
public partial class XmlBingFrm : Form
{
public XmlBingFrm()
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterScreen;
this.txtPath.ReadOnly = true;
this.txtPath.Enabled = false;
}
void btnImportXml_Click(object sender, EventArgs e)
{
using (OpenFileDialog ofdXml = new OpenFileDialog())
{
ofdXml.Multiselect = false;
ofdXml.Title = "导入XML文件";
ofdXml.Filter = "XML文件(*.xml)|*.xml";
if (ofdXml.ShowDialog() == DialogResult.OK)
{
string path=ofdXml.FileName;
this.txtPath.Text =path;
try
{
Cursor.Current = Cursors.WaitCursor;
Thread th = new Thread(() =>
{
this.LoadEditXML(path);
});
th.IsBackground = true;
th.Start();
//Thread.Sleep(1000);
Cursor.Current = Cursors.Arrow;
MessageBox.Show("更新XML成功!");
}
catch (Exception ex)
{
Cursor.Current = Cursors.Arrow;
MessageBox.Show("更新XML失败,原因:" + Environment.NewLine + ex.Message);
}
}
}
}
private void LoadEditXML(string path)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(path);
XmlNodeList pageXnl = xmlDoc.SelectNodes("pages/page");
foreach (XmlNode xn in pageXnl)
{
XmlNodeList xp = xn.SelectNodes("page");
string page = string.Empty;
foreach (XmlNode xd in xp)
{
page = xd.Attributes["pageNum"].Value;
DataTable dt = null;
int count = 0;
dt = Medias.GetRochXml(page);
if (dt != null)
{
count = dt.Rows.Count;
if (count > 0)
{
string key = string.Empty;
foreach (DataRow dr in dt.Rows)
{
key += dr["key"].ToString() + ",";
}
key = key.TrimEnd(',');
XmlElement xe = (XmlElement)xd;
xe.SetAttribute("key", key);
xmlDoc.Save(path);
}
}
}
}
}
}
}
------------------------
背景图单独存放在其它位置后,当窗口的OnResize事件发生时,
对图片缩放后,作为背景。这里借用了一个pictureBox.不改变它的其它属性,如改变Image属性后,编写如下代码。
private void Form2_SizeChanged(object sender, System.EventArgs e)
{
loadBackImage();
}
private void loadBackImage()
{
Bitmap bit = new Bitmap(this.Width,this.Height);
Graphics g = Graphics.FromImage(bit);
g.DrawImage(this.pictureBox1.Image,new Rectangle(0,0,bit.Width,bit.Height),0,0,this.pictureBox1.Image.Width,this.pictureBox1.Image.Height,GraphicsUnit.Pixel);
this.BackgroundImage = bit;
g.Dispose();
}
private void Form2_Load(object sender, System.EventArgs e)
{
loadBackImage();
}
----------------- 总忘记---------------------
现象:ASP.NET后台写入中文COOKIE后,前台用JS读取为乱码
解决:
后台ASP.NET写入
HttpContext.Current.Request.Cookies[“cookiename”].Value = System.Web.HttpUtility.UrlEncode(strValue,Encoding.UTF8);
前台JS读取
使用decodeURIComponent解码显示
-------------------------------------------------
Request.Form:获取以POST方式提交的数据(接收Form提交来的数据);
Request.QueryString:获取地址栏参数(以GET方式提交的数据)
Request:包含以上两种方式(优先获取GET方式提交的数据),它会在QueryString、Form、ServerVariable中都按先后顺序搜寻一遍。
而且有时候也会得到不同的结果。如果你仅仅是需要Form中的一个数据,但是你使用了Request而不是Request.Form,那么程序将在QueryString、ServerVariable中也搜寻一遍。如果正好你的QueryString或者ServerVariable里面也有同名的项,你得到的就不是你原本想要的值了。
Request.Params是所有post和get传过来的值的集合,request.params其实是一个集合,它依次包括request.QueryString、request.Form、request.cookies和request.ServerVariable。
Get Post 的区别
1、Get是用来从服务器上获得数据,而Post是用来向服务器上传递数据。
2、Get将表单中数据的按照variable=value的形式,添加到action所指向的URL后面,并且两者使用“?”连接,而各个变量之间使用“&”连接;Post是将表单中的数据放在form的数据体中,按照变量和值相对应的方式,传递到action所指向URL。
3、Get是不安全的,因为在传输过程,数据被放在请求的URL中,而如今现有的很多服务器、代理服务器或者用户代理都会将请求URL记录到日志文件中,然后放在某个地方,这样就可能会有一些隐私的信息被第三方看到。另外,用户也可以在浏览器上直接看到提交的数据,一些系统内部消息将会一同显示在用户面前。Post的所有操作对用户来说都是不可见的。
4、Get传输的数据量小,这主要是因为受URL长度限制;而Post可以传输大量的数据,所以在上传文件只能使用Post(当然还有一个原因,将在后面的提到)。
5、Get限制Form表单的数据集的值必须为ASCII字符;而Post支持整个ISO10646字符集。
6、Get是Form的默认方法。
=====================================================================================
Request.Params 获取Request.QueryString和Request.Form等项的集合。
Request.QueryString:接受URL等查询字符串的集合。
Request.Form:是用来接受窗体表单等变量。
Request.QueryString和Request.Form以前都是专门针对asp页面的,当asp页面的form的method属性为get 时,使用querystring,为post时,使用form.
剩下的那个同楼上
a调用b
Request.QueryString:
a.asp: response.redirect "b.aspx?id=123"
b.asp: 得到数据id的值则 dim sId=Request.QueryString("id")
Request.Form:
a.asp:
<form>
...
<asp:text id="pName" .../>
...
</form>
b.asp:得到数据id的值则 dim sName=Request.Form("pName")
Request.Params:.NET里面取得参数的方法,上面两种传递方式哪种都可以
b.aspx.cs:
string sId=Request.Params("id")
string sName=Request.Params("pName")