松架东的风声

Web 改变生活, DotNet 改变Web

导航

公告

收藏夹

随笔档案

最新评论

统计

常用链接

收藏

阅读排行榜

评论排行榜

2005年8月17日 #

使用反射技术在asp.net页间传递对象

posted @ 2005-08-17 14:44 松架东的风声 阅读(1416) 评论(7) 编辑

2004年9月8日 #

在asp.net中防止按钮多次点击提交的办法!

asp.net中防止按钮多次点击提交的办法!  
为提交button 加上下面的属性:

 

System.Text.StringBuilder sb = new System.Text.StringBuilder();

                            sb.Append("if (typeof(Page_ClientValidate) == 'function') { ");

                            sb.Append("if (Page_ClientValidate() == false) { return false; }} ");

                            sb.AppendFormat("this.value = '{0}';", this.waitText);

                            sb.Append("this.disabled = true;");

                            sb.Append(this.Page.GetPostBackEventReference(this));

                            sb.Append(";");

                            this.Attributes["onclick"] = sb.ToString();   

 如果页面上没有校验控件. 可以直接用下面的:

 this.Button1.Attributes.Add("onclick",
                "this.value='Please wait...';this.disabled = true;"
                    + this.GetPostBackEventReference(this.Button1));

posted @ 2004-09-08 10:03 松架东的风声 阅读(1074) 评论(0) 编辑

2004年5月10日 #

一小时了, 写了三行代码! 把上面三行换成下面三行.

//XmlNodeList xmlNodeList = inXmlDoc.SelectNodes("//" +field);
    //    foreach(XmlNode node in xmlNodeList)
    //    {
    //     node.ParentNode.RemoveChild(node);
    //    }

    XmlNodeList xmlNodeList = inXmlDoc.GetElementsByTagName(field);

    while ( xmlNodeList[0] != null )
    {
     xmlNodeList[0].ParentNode.RemoveChild(xmlNodeList[0]); 
    }

posted @ 2004-05-10 18:09 松架东的风声 阅读(798) 评论(0) 编辑

2004年4月22日 #

几个 XmlTextReader 的例子, 帮了我大忙.

using System;
using System.IO;
using System.Text;
using System.Xml;

namespace foo {
public class bar {
public static void Main() {
Test1();
Test2();
Test3();

}

public static void Test1() {
string strInput = "<?xml version='1.0' encoding='utf-16'?><foo><bar /></foo>";
XmlTextReader r = new XmlTextReader(new StringReader(strInput));
StringBuilder sb = new StringBuilder();
XmlTextWriter w = new XmlTextWriter(new StringWriter(sb));
w.WriteNode(r, false);
w.Flush();
string strOutput = sb.ToString();
Console.WriteLine("Input = {0}, Output = {1}", strInput.Length, strOutput.Length);
}

public static void Test2() {
string strInput = "<?xml version='1.0' encoding='utf-16'?><foo><bar /></foo>";
XmlTextReader r = new XmlTextReader(new StringReader(strInput));
MemoryStream ms = new MemoryStream();
XmlTextWriter w = new XmlTextWriter(ms, Encoding.Unicode);
w.WriteNode(r, false);
w.Flush();
ms.Position = 0;
StreamReader sr = new StreamReader(ms);
string strOutput = sr.ReadToEnd();
Console.WriteLine("Input = {0}, Output = {1}", strInput.Length, strOutput.Length);
}

public static void Test3() {
string strInput = "<?xml version='1.0' encoding='utf-16'?><foo><bar /></foo>";
XmlTextReader r = new XmlTextReader(new StringReader(strInput));
MemoryStream ms = new MemoryStream();
XmlTextWriter w = new XmlTextWriter(ms, Encoding.UTF8);
w.WriteNode(r, false);
w.Flush();
ms.Position = 0;
StreamReader sr = new StreamReader(ms);
string strOutput = sr.ReadToEnd();
Console.WriteLine("Input = {0}, Output = {1}", strInput.Length, strOutput.Length);
}


}
}

posted @ 2004-04-22 17:36 松架东的风声 阅读(3960) 评论(0) 编辑

仅列出标题