以编程方式在客户端上保存ASPX页面 [英] Save ASPX page on client programmatically

查看:65
本文介绍了以编程方式在客户端上保存ASPX页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


场景:


有一个ASPX页面显示一些文字并且在

底部:保存,打印和关闭。打印和关闭由javascript完成。但是如何将
保存在客户端的计算机上呢?他/她可以使用

浏览器(文件/保存)执行此操作,但我需要按下按钮完成此操作。


在我的服务器端代码我得到了按钮点击事件,我也知道如何获取

数据给客户端(包括文件保存对话框),但我在哪里可以获得

页面的内容?


下载代码看起来像这样(实际上我的问题是???):


回复.AddHeader(" Content-Disposition"," attachment;

filename = Contract.html");

Response.AddHeader(" Content-Length" ,? ??。Length.ToString());

Response.ContentType =" application / octet-stream";

Response.Write(???);

Response.End();


也许我完全错了,还有另外一种更好的方法。请

帮助!

Hello,

the scenario:

There''s an ASPX page which shows some text and has three buttons at the
bottom: Save, Print and Close. Print and close is done by javascript. But how
can I save the page on the client''s computer? He/she could do this using the
browser (file/save), but I need to have it done by pressing the pushbutton.

In my serverside code I get the button-click-event, I also know how to get
data to the client (including file-save-dialog), but where can I get the
page''s content?

The download code could look like this (with ??? being actually my question):

Response.AddHeader("Content-Disposition", "attachment;
filename=Contract.html");
Response.AddHeader("Content-Length", ???.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Write(???);
Response.End();

Maybe I''m completely wrong and there is an other better way to do it. Please
help!

推荐答案

这取决于您希望用户保存什么。由于它是Web应用程序,因此根据HTML标记,所有用户获取的是在浏览器中呈现的页面。如果你希望用户按原样保存页面,那么浏览器的保存按钮就可以了。菜单是

这意味着什么,为什么要尝试再次发明轮子。如果您希望用户保存的是页面上显示的数据,但是采用不同的格式(例如,PDF),

您需要重新组织数据按需格式并发送到浏览器

作为下载流。或者因为当前页面有太多的装饰,

你想要保存一个干净的可打印版本,那么你可以简单地制作一个简单的

可打印版本的页面,到让用户仍然可以使用

标准浏览器保存保存命令。


我没有看到用户可以轻松保存页面的重点,而你仍然希望他能保存与下载完全相同的页面a保存按钮。

" FreeNEasy" < Fr ******* @ community.nospamwrote in message

新闻:B1 *********************** *********** @ microsof t.com ...
It depends on what do you want user to save. Since it is web application,
all user gets is a page rendered in a browser, according to HTML tags. If
you want user to save the page as it is, then the browser''s "Save" menu is
what it means, why try to invent the wheel again. If what you want user to
save is the data displayed on the page, but in different format (say, PDF),
you need then to re-organise your data in wanted format and send to browser
as download stream. Or because of the current page has too many decorations,
you want to save a clean printable version, then you can simply make a plain
printable version of the page, to let user still be able to save with
standard browser "Save" command.

I do not see the point when user can save the page easily, while you still
want him to save the exactly same page as download via a "Save" button.
"FreeNEasy" <Fr*******@community.nospamwrote in message
news:B1**********************************@microsof t.com...

您好,


场景:


有一个ASPX页面显示一些文本,并在

底部有三个按钮:保存,打印和关闭。打印和关闭由javascript完成。但是

怎么用/ b $ b我可以将页面保存在客户端的计算机上吗?他/她可以使用

浏览器(文件/保存)来执行此操作,但我需要按

按钮完成此操作。


在我的服务器端代码中,我得到了按钮点击事件,我也知道如何向客户端获取

数据(包括文件保存 - 对话框),但是我在哪里可以获得

页面的内容?


下载代码看起来像这样(???实际上是我的

问题):


Response.AddHeader(" Content-Disposition"," attachment;

filename = Contract。 html");

Response.AddHeader(" Content-Length",???。Length.ToString());

Response.ContentType =" application / octet-stream" ;;

Response.Write(???);

Response.End();


也许我'完全错了,还有另一种更好的方法。



帮忙!
Hello,

the scenario:

There''s an ASPX page which shows some text and has three buttons at the
bottom: Save, Print and Close. Print and close is done by javascript. But
how
can I save the page on the client''s computer? He/she could do this using
the
browser (file/save), but I need to have it done by pressing the
pushbutton.

In my serverside code I get the button-click-event, I also know how to get
data to the client (including file-save-dialog), but where can I get the
page''s content?

The download code could look like this (with ??? being actually my
question):

Response.AddHeader("Content-Disposition", "attachment;
filename=Contract.html");
Response.AddHeader("Content-Length", ???.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Write(???);
Response.End();

Maybe I''m completely wrong and there is an other better way to do it.
Please
help!



错误的新闻组,但你可以使用像document.innerHTML

或document.innerText之类的东西。


问题在于它不包括图像或任何包含的内容

等IE的客户端保存实际上做了很多工作。


" FreeNEasy" < Fr ******* @ community.nospamwrote in message

新闻:B1 *********************** *********** @ microsof t.com ...
Wrong newsgroup, but you can probably usee something like document.innerHTML
or document.innerText or something.

The problem with that is that it won''t include images or anything included
etc. IE''s client save is actually doing a lot of work.

"FreeNEasy" <Fr*******@community.nospamwrote in message
news:B1**********************************@microsof t.com...

您好,


场景:


有一个ASPX页面显示一些文本,并在

底部有三个按钮:保存,打印和关闭。打印和关闭由javascript完成。但是

怎么用/ b $ b我可以将页面保存在客户端的计算机上吗?他/她可以使用

浏览器(文件/保存)来执行此操作,但我需要按

按钮完成此操作。


在我的服务器端代码中,我得到了按钮点击事件,我也知道如何向客户端获取

数据(包括文件保存 - 对话框),但是我在哪里可以获得

页面的内容?


下载代码看起来像这样(???实际上是我的

问题):


Response.AddHeader(" Content-Disposition"," attachment;

filename = Contract。 html");

Response.AddHeader(" Content-Length",???。Length.ToString());

Response.ContentType =" application / octet-stream" ;;

Response.Write(???);

Response.End();


也许我'完全错了,还有另一种更好的方法。



帮忙!
Hello,

the scenario:

There''s an ASPX page which shows some text and has three buttons at the
bottom: Save, Print and Close. Print and close is done by javascript. But
how
can I save the page on the client''s computer? He/she could do this using
the
browser (file/save), but I need to have it done by pressing the
pushbutton.

In my serverside code I get the button-click-event, I also know how to get
data to the client (including file-save-dialog), but where can I get the
page''s content?

The download code could look like this (with ??? being actually my
question):

Response.AddHeader("Content-Disposition", "attachment;
filename=Contract.html");
Response.AddHeader("Content-Length", ???.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Write(???);
Response.End();

Maybe I''m completely wrong and there is an other better way to do it.
Please
help!



@Norman:


你是对的,浏览器的保存功能会对此没问题。还有

我需要在页面上有一个按钮的两个原因:


原因1:无意冒犯某人:有用户在那里

他们不知道这些以及他们如何保存浏览器中显示的页面。

由于该文件是合同文件,重要的是用户

可以保存它,(并保存它)一个清晰可见的保存按钮是保存文件的更安全的方式。


原因2:我正在为客户编程并且他想要保存按钮。


此外,如果我想修改内容以进行格式化等。我首先要求b $ b需要有内容。 ASPX页面由带有文本和

字段的表单组成,如何获取呈现的内容,我找不到它。


" ; Norman Yuan写道:
@Norman:

You are right, the browser''s save function would be fine for this. There are
two reasons why I need to have a button on the page for it:

reason 1: Without the intention to offend someone: there ARE users out there
who don''t know THAT and HOW they can save a page displayed in their browser.
Since the document is a contract document and it is important that the user
can save it, (and does save it) a clearly visible save-button is the more
secure way to have the document saved.

reason 2: I am programming this for a customer and he WANTS the save-button.

Besides, if I would like to modify the content for formatting etc. I first
need to have the content. The ASPX page ist made of a form with text and
fields, how can I get the rendered content, I can''t find it.

"Norman Yuan" wrote:

这取决于您希望用户保存什么。由于它是Web应用程序,因此根据HTML标记,所有用户获取的是在浏览器中呈现的页面。如果你希望用户按原样保存页面,那么浏览器的保存按钮就可以了。菜单是

这意味着什么,为什么要尝试再次发明轮子。如果您希望用户保存的是页面上显示的数据,但是采用不同的格式(例如,PDF),

您需要重新组织数据按需格式并发送到浏览器

作为下载流。或者因为当前页面有太多的装饰,

你想要保存一个干净的可打印版本,那么你可以简单地制作一个简单的

可打印版本的页面,到让用户仍然可以使用

标准浏览器保存保存命令。


我没有看到用户可以轻松保存页面的重点,而你仍然希望他能保存与下载完全相同的页面a保存按钮。


" FreeNEasy" < Fr ******* @ community.nospamwrote in message

新闻:B1 *********************** *********** @ microsof t.com ...
It depends on what do you want user to save. Since it is web application,
all user gets is a page rendered in a browser, according to HTML tags. If
you want user to save the page as it is, then the browser''s "Save" menu is
what it means, why try to invent the wheel again. If what you want user to
save is the data displayed on the page, but in different format (say, PDF),
you need then to re-organise your data in wanted format and send to browser
as download stream. Or because of the current page has too many decorations,
you want to save a clean printable version, then you can simply make a plain
printable version of the page, to let user still be able to save with
standard browser "Save" command.

I do not see the point when user can save the page easily, while you still
want him to save the exactly same page as download via a "Save" button.
"FreeNEasy" <Fr*******@community.nospamwrote in message
news:B1**********************************@microsof t.com...

您好,


场景:


有一个ASPX页面显示一些文本,并在

底部有三个按钮:保存,打印和关闭。打印和关闭由javascript完成。但是

怎么用/ b $ b我可以将页面保存在客户端的计算机上吗?他/她可以使用

浏览器(文件/保存)来执行此操作,但我需要按

按钮完成此操作。


在我的服务器端代码中,我得到了按钮点击事件,我也知道如何向客户端获取

数据(包括文件保存 - 对话框),但是我在哪里可以获得

页面的内容?


下载代码看起来像这样(???实际上是我的

问题):


Response.AddHeader(" Content-Disposition"," attachment;

filename = Contract。 html");

Response.AddHeader(" Content-Length",???。Length.ToString());

Response.ContentType =" application / octet-stream" ;;

Response.Write(???);

Response.End();


也许我'完全错了,还有另一种更好的方法。



帮忙!
Hello,

the scenario:

There''s an ASPX page which shows some text and has three buttons at the
bottom: Save, Print and Close. Print and close is done by javascript. But
how
can I save the page on the client''s computer? He/she could do this using
the
browser (file/save), but I need to have it done by pressing the
pushbutton.

In my serverside code I get the button-click-event, I also know how to get
data to the client (including file-save-dialog), but where can I get the
page''s content?

The download code could look like this (with ??? being actually my
question):

Response.AddHeader("Content-Disposition", "attachment;
filename=Contract.html");
Response.AddHeader("Content-Length", ???.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Write(???);
Response.End();

Maybe I''m completely wrong and there is an other better way to do it.
Please
help!






这篇关于以编程方式在客户端上保存ASPX页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆