C# Asp.NET 生成GOOGLE地图和索引
(1)首先要对内容的特殊字符进行过虑:
C# 代码:
public string res(string partno)
{
partno = partno.Replace("&", "");
partno = partno.Replace("/", "");
partno = partno.Replace("&", "");
return partno;
}
(2)从数据库中获得要生成地图的内容:
C# 代码:
public void getXMLSitemapData(StreamWriter writerFile,int minid,int maxid)
{
SqlConnection mycon = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
string sqlstr = "Select id,name from table where id>'" + minid + "' and id <'" + maxid + "'";//数据库内容语句
SqlCommand cmd = new SqlCommand(sqlstr, mycon);
mycon.Open();
SqlDataReader rdr = cmd.ExecuteReader();
if (rdr.HasRows)
{
while (rdr.Read())
{
writerFile.WriteLine("<url>");
writerFile.WriteLine("<loc>" + "http://www.uni888.com/" + res(rdr[1].ToString())+".html" + "</loc>");
writerFile.WriteLine("<lastmod>" +"2009-04-22"+ "</lastmod>");
writerFile.WriteLine("<changefreq>weekly</changefreq>");
writerFile.WriteLine("<priority>1.0</priority>");
writerFile.WriteLine("</url>");
}
}
rdr.Close();
mycon.Close();
}
(3)创建并写入sitemaps.xml GOOGLE地图
C# 代码:
public void createXMLSitemap(int minid,int maxid,int maps)
{
FileInfo XMLFile = null;
StreamWriter WriteXMLFile = null;
string FilePath = HttpContext.Current.Server.MapPath("sitemap"+maps+".xml");
XMLFile = new FileInfo(FilePath);
WriteXMLFile = XMLFile.CreateText();
//下面两句话必须写,而且不能做任何修改
WriteXMLFile.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
WriteXMLFile.Wri
相关文档:
/*
本段代码在公司项目中实际远程调用第三方公司提供的C#开发WebService的示例
*/
/**
* 登录游戏
*
* @param paramPN
* @param paramTerraceID
* @param paramSvrID
*/
private String loginGame(String paramPN, HttpServletRequest req){
&n ......
日期转化一
为了达到不同的显示效果有时,我们需要对时间进行转化,默认格式为:2007-01-03 14:33:34 ,要转化为其他格式,要用到DateTime.ToString的方法(String, IFormatProvider),如下所示:
using System;
using System.Globalization;
String format="D";
DateTime date=DataTime,Now;
Response.Write(date.ToS ......
The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller. The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating MVC-based Web applications. The ASP.NET MVC framework is ......
ASP.NET获取客户端信息,暂时就这几个,有待添加~~
1. 在ASP.NET中专用属性:
获取服务器电脑名:Page.Server.ManchineName
获取用户信息:Page.User
获取客户端电脑名:Page.Request.UserHostName
获取客户端电脑IP:Page.Request.UserHostAddress
2. 在网络编程中的通用方法:
获取当前电脑名:static System. ......
1.上传功能
JS检查
function hideUpImg()//关闭层,并上传图片
{
var v=document.getElementById("upImg").value;
var after=v.substring(v.lastIndexOf('.')).toLowerCase();
alert(after);
if(v.length<=0)
{
alert("请选择图片");
return ......