asp.net页面静态化
方法一:
HtmlProxy.cs:
using System.Text;
using System.IO;
/// <summary>
/// HtmlProxy 的摘要说明
/// </summary>
public class HtmlProxy
{
public HtmlProxy()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static bool ChangeFile(int id)
{
string filename = HttpContext.Current.Server.MapPath("Post_" + id + ".html");
//尝试读取已有文件
Stream st = GetFileStream(filename);
//如果文件存在并且读取成功
if (st != null) //文件存在
{
using (st)
{
StreamToStream(st, HttpContext.Current.Response.OutputStream);
return true;
//Response.End();
}
}
Else //文件不存在,根据ForumDetail.aspx页面的内容创建文件
{
StringWriter sw = new StringWriter();
HttpContext.Curre
相关文档:
//以下代码根据别人文章和自己整理
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace WebApplication1
{
public partial class DownfFile : System.Web.UI.Page
{
p ......
在ASP.NET 1.1中,要做1个弹出的确认对话框的话,一般是在服务端的代码中这样写:
private void Page_Load(object sender, System.EventArgs e)
{
btnClick.Attributes.Add("onclick", "return confirm('Are you sure?');");
// Button1.Attributes["OnClick"] = "return conf ......
一、用JQuery的Ajax加载XML并解析的注意事项
1、Content-Type
很多时候无法解析就是Content-Type的问题。如果本身就是XML文件,请跳过这一步。
动态生成的XML一定要将其设置为text/xml,否则默认就是text/html也就是普通的文本。 常见语言的Content-Type设置:
  ......
Asp.net 后台调用js方法(转)
1. 用Response.Write方法
代码如下:
Response.Write("<script type='text/javascript'>alert("XXX");</script>");
此方法缺陷就是不能调用脚本文件中的自定义的函数,只能调用内部函数,具体调用自定义的函数只能在Response.Write写上函数定 义,比如
Response.Write("& ......
<asp:TemplateField HeaderText="测试">
<ItemTemplate>
<asp:LinkButton ID="test" runat="server" OnClick="test_Click" OnClientClick='<%# string.Format("return confirmDelete(\"{0} {1}\");", DoEscape((string)Eval( ......