PDA

View Full Version : دستور برای ذخیره صفحه هست؟



elham1611
پنج شنبه 16 شهریور 1391, 15:39 عصر
با سلام
با چه دستوری میشه صفحه جاری رو ذخیره کرد؟ البته با دستورات asp.net
کدهای جاوا اسکریپت مثل کد زیر در کروم و فایرفاکس کار نمیکنن.


document.execCommand("SaveAs")

meisam12
پنج شنبه 16 شهریور 1391, 19:34 عصر
سلام
از سورس زیر استفاده کن.

protected void Page_Load(object sender, EventArgs e)
{
if( !IsPostBack )
{
ViewState["RefUrl"] = Request.UrlReferrer.ToString();
}
}

elham1611
پنج شنبه 16 شهریور 1391, 20:21 عصر
ممنون ولی کار نمیکنه
من یک buttom در صفحه گذاشتم و در رویدادش دستور شما رو نوشتم ولی وقتی روی دکمه میزنی هیچ اتفاقی نمیافته
من میخوام صفحه رو ذخیره کنه مثل save as که درخواست ذخیره رو اجرا میکنه

meisam12
پنج شنبه 16 شهریور 1391, 22:44 عصر
ببین از این سورس می تونی نتیجه بگیری.

private void saveCurrentAspxToHTML()
{
string HTMLfile = "http://localhost:4997/MEA5/AEPRINT.aspx?id=" +
Convert.ToString(frmae.AeEventid) +
"&eid=" +
Convert.ToString(frmae.AeEnquiryid);

WebRequest myRequest = WebRequest.Create(HTMLfile);

// Return the response.
WebResponse myResponse = myRequest.GetResponse();

// Obtain a 'Stream' object associated with the response object.
Stream ReceiveStream = myResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");

// Pipe the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(ReceiveStream, encode);

// Read 256 charcters at a time.
Char[] read = new Char[256];
int count = readStream.Read(read, 0, 256);

using (StreamWriter sw = new StreamWriter(Server.MapPath("~") + "\\MyPage.htm"))
{
while (count > 0)
{
// Dump the 256 characters on a string and display the string onto the console.
String str = new String(read, 0, count);
sw.Write(str);
count = readStream.Read(read, 0, 256);
}
}

// Close the response to free resources.
myResponse.Close();

}