输出PDF文档到ASP.NET页面
protected
void Page_Load(object sender, EventArgs e)
{
try
{
//query the pdf path
string pdfna =
this.Request.QueryString["pdf"];
if (pdfna == null)
throw new Exception("This
page can not be accessed directly");
string pdf = "Reports\\" +
pdfna;
pdf = Server.MapPath(pdf);
//read all bytes
if (File.Exists(pdf) == false)
throw new Exception("This
report is not created");
FileStream fs = File.Open(pdf,
FileMode.Open);
byte[] buffer = new
byte[fs.Length];
fs.Read(buffer, 0,
buffer.Length);
fs.Close();
//write to response
Response.ContentType =
"application/pdf";
Response.AddHeader(
相关文档:
一.后台调用前台
1.Page.ClientScript.RegisterStartupScript(type,"",script);
例:
string script = string.Format("<script>alert('Wrong');</script>");
Page.ClientScript.RegisterStartupScript(GetType(), "Load", script);
2.对象.Attributes.Add("事件","script")
例:
e.Row.Attributes.Add("on ......
在最近开始将AJAX技术加入到日常的开发工作中。我在最近写了个AJAX的无刷新登陆且动态添加服务器控件的工作,我将此功能告诉大家希望对大家的工作有所帮助。如果大家有更好的方法且愿意在此留言让我也可以分享到你的成果。
首先在页面中的HTML标记中加入控件UpdatePanel和两个Textbox一个Button:
<asp:UpdatePanel ID ......
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace class_new
{
/// <summary>
/// DataClass 的摘要说明。
/// </summary>
public class DataClass
{
private string strConnection="";
&n ......
asp.net中application,session,cookie,viewstate,cache对象
在asp.net中内置对象如application,session,cookie,viewstate,cache等的生存周期和应用范围从大到小为application,cache,session,cookie,viewstate.
application和cache的应用范围都是在整个应用程序中.而session,cookie,viewstate则是基于每个用户,application ......
前言
写这篇文章的目的,是想总结一些东西,以帮助朋友们更好的使用这个框架。但是,我又不像把官方列举的哪些优势、功能翻译过来列举在这里。所以,我想干脆我就纯从个人观点上对这个框架评论一下吧。说的不好的,不对的还请批评指正。
ASP.NET MVC——螺旋进步的产物
对于微软为什么要推出ASP.NET MVC,我们 ......