用asp.net生成html静态页的两种方法~~~
第一种方法是对一个aspx页面生成html文件,先对服务器发送请求aspx页面,取服务器返回的html流,写到一个html文件里,aspx页面显示的是什么,生成的html页面就是什么
1、asp方法:
sub createHTML
dim xmlhttp,strhtml,objAdoStream,i,myurl
set xmlhttp=server.CreateObject("Microsoft.XMLHTTP")
Randomize
i=Int((100 * Rnd) + 1)' 产生1到100之间的随机数,强制从数据库取数据
myurl="asp页面文件名.asp?i=" &i
xmlhttp.open "GET",myurl,false
xmlhttp.send
strhtml=xmlhttp.responsebody
set objAdoStream = Server.CreateObject("ADODB.Stream")
objAdoStream.Type = 1
objAdoStream.Open
objAdoStream.Write strhtml
objAdoStream.SaveToFile server.MapPath("default.htm"),2
objAdoStream.Close
response.Write("成生完毕")
end sub
2、VB.NET做脚本的时候的asp.net方法:(载自:http://erqie.bokee.com/5641140.html)
引用命名空间
Imports System.Net
Imports System.IO
Dim strHtml As String
Dim sr As StreamReader
Dim sw As StreamWriter
Dim code As Encoding = Encoding.GetEncoding("utf-8")
Dim HttpWebRequest As WebRequest
Dim HttpWebResponse As WebResponse
HttpWebRequest = WebRequest.Create("http://localhost/test.aspx")
HttpWebResponse = HttpWebRequest.GetResponse
sr = New StreamReader(HttpWebResponse.GetResponseStream, code)
strHtml = sr.ReadToEnd
sw = New StreamWriter(Server.MapPath("a.htm"), False, code)
sw.WriteLine(strHtml)
sw.Flush()
sw.Close()
Response.WriteFile(Server.MapPath("a.htm"))
3、用C#做脚本的asp.net的方法,这个是我自己写的,在《Visual C#.NET范例入门与提高》的P311,有对WebRequest和HttpRequest、HttpWebRequest、HttpWebResponse四个类的简单说明
private bool CreateList
相关文档:
欢迎进入.NET社区论坛,与200万技术人员互动交流 >>进入
ASP.NET 数据控件:GridView,DataList,Repeater ,DetailsView,FormView。
ASP.NET 数据控件综述:
1.前3个用于呈现多条记录,后面2个用于呈现单条数据明细,即常用的记录明细。
2.GridView和DetailsView控件的布局固定,自定义数据显示的布局功能有限,一般 ......
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
< ......
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 ......
在Asp.net中实现文件的上传功能,是非常简单的一件事情,只需要利用微软提供的FileUpload控件即可轻松实现。
LargeFileUpload.aspx代码如下
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="LargeFileUpload.aspx.vb"
Inherits="LargeFileUpload" %>
<!DOCTYPE html PUBLIC "-//W3C/ ......
(1)首先要对内容的特殊字符进行过虑:
C# 代码:
public string res(string partno)
{
partno = partno.Replace("&", "");
partno = partno.Replace("/", "");
partno = partno.Replace("&", "");
return partno;
}
(2)从数据库中获得要生成地图的内 ......