//用javascript判断是否去那个页面
Response.Write("<script language=\"javascript\" type=\"text/javascript\">");
Response.Write("if(confirm('是否去那个页面。')){ document.URL='LookContent.aspx'}");
Response.Write("</script>");
//传递信息时如果有中文最好用以下函数转换一下HttpUtility.UrlEncode()
http://www.abc.com/SameArticle.aspx?type=classify&title=" + HttpUtility.UrlEncode("标题")
//获取某页面传递过来的问号信息
Request.QueryString["title"]
//获取服务器路径
System.Web.HttpRuntime.AppDomainAppPath
//日期胡乱转换
string dtString = "19831015121015";
IFormatProvider culture = new System.Globalization.CultureInfo("zh-CN", true);
DateTime dt = DateTime.ParseExact(dtString, "yyyyMMddHHmmss", culture, DateTimeStyles.NoCurrentDateDefault); //大写HH是24小时制,小写hh是12小时制
Console.WriteLine(dt.ToString());
//DataTable 排序方法
DataView dvBriefing = dtBriefing.DefaultView;
dvBriefing.Sort = "CommentCount DESC";
dtBriefing = dvBriefing.ToTable();
//Asp.net 快速写txt文件
StreamWriter swOutTime = new StreamWriter("c:\\TempOutTime.txt", true, System.Text.Encoding.GetEncoding("GB2312"));
swOutTime.Write("写入txt文件");
swOutTime.Flush();
swOutTime.Close();
//Asp.net DataTable写XML
1、写用dtBriefing.WriteXml("C:\\temp.xml", XmlWriteMode.WriteSchema);
2、读用DataSet dllxml = new DataSet();
dllxml.ReadXml("C:\\temp.xml");
dtBriefing = dllxml.Tables[0];
// 判断是否合法的IP地址
static private bool isIpAdd(string url)
{
url = CleanURL(url);
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"(\d{1,3}\.){3}\d{1,3}");
if (url == reg.Match(url).ToString())
{
if (reg.Match(url).Success)
{
string[] ips = url.Split('.');
if (ips.Length == 4 || ips.Length == 6)
{
if (System.Int32.Parse(ips[0]) < 256 && System.Int32.Parse(ips[1]) < 256 & System.Int32.Parse(ips[2]) < 256 & System.Int32.Parse(ips[3]) < 256)
return true;
else
return false;
}
}
}
return false;
}
转载于:https://www.cnblogs.com/ghostljj/archive/2007/01/25/630230.html