ASP: Hvor finder jeg ref. kode
Hej alleJeg har et problem med udskrift fra et ældre asp kodet website og har fundet løsningen, men jeg kan desværre ikke finde frem til hvor dette er placeret.
Problem er angående<div style="page-break-before:always"></div>
Hver side har en aspx fil og en aspx.cs fil.
1. Jeg har en side med en trykknap:
<asp:Button ID="Button_PrintAll" runat="server" Text="Udskriv alle viste punkter" OnClick="Button_PrintAll_Click"/>
tilhørende ASPX.cs fil:
protected void Button_PrintAll_Click(object sender, EventArgs e)
{
Util util = new Util();
string s = LatestWhereClause();
string sql =
"insert into alarm.batch(recid,action,parm1,parm2,parm3,parm4,targetfile) values " +
"(appseq.nextval,'printmany'," + (new MySqlLayer()).SqlLit(s) + ",0,'',''," + (new MySqlLayer()).SqlLit(htmfilename) + ")";
util.SqlNonQuery(sql);
Master.GridDefinition.BuildGrid();
Response.Write("<script>window.open('ShowHtm.aspx?id=" + htmfilename + "','Alarminstruks','alwaysraised=yes,dependent=yes,location=no,menubar=yes,status=no');</script>");
}
2. Showhtm.aspx giver ikke rigtig noget svar
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ShowHtm.aspx.cs" Inherits="ShowPdf" UICulture="da-DK" %>
<!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" >
<head runat="server">
<title></title>
</head>
<body charset="windows-1252">
<form id="form1" runat="server">
<div>
<asp:Label ID="Label_time" runat="server" Text=""></asp:Label><p></p>
<script>
setTimeout("reloadpage()", 1000);
function reloadpage() { document.location.reload(); }
</script>
<asp:HyperLink ID="HyperLink1" visible=false runat="server">Klik her hvis pdf-filen ikke vises automatisk.</asp:HyperLink>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label><p></p>
<asp:Button ID="Button1"
runat="server" Text="Fortryd" OnClientClick="window.close()" />
</div>
</form>
<script>postLoad();</script>
</body>
</html>
Showhtm.aspx.cs:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.IO;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ShowPdf : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label_time.Text= DateTime.Now.ToString();
try
{
string pdffilename = Request["id"];
string webname = "temp/" + pdffilename.Replace(".pdf","_.pdf");
string physName = Server.MapPath(webname);
bool fileReady = false;
if (System.IO.File.Exists(physName))
{
try
{
FileStream fs = System.IO.File.Open(physName,FileMode.Open,FileAccess.Read,FileShare.ReadWrite);
fs.ReadByte();
fs.Close();
fileReady = true;
}
catch
{
}
}
if (fileReady) {
Response.Charset = "utf-8";
//Response.WriteFile(physName);
//Response.Write("<script>document.location.replace('temp/"+pdffilename+"');</script>");
Response.Redirect("temp/" + pdffilename, true);
Response.End();
/*FileStream pdfStream = new FileStream(physName,FileMode.Open, FileAccess.Read);
Response.ContentType = "application/pdf";
MemoryStream memStream = new MemoryStream();
Response.AddHeader("content-length",
System.Convert.ToString(pdfStream.Length));
//Response.BinaryWrite(pdfStream.);
*/
/*****************************
* HyperLink1.NavigateUrl = webname;
HyperLink1.Visible = true;
Response.Write("<script>function postLoad() { document.getElementById('" + HyperLink1.ClientID + "').click(); }</script>");
* */
/*
Response.Clear();
Response.ContentType = "application/pdf";
Response.WriteFile(physName);
*/
} else {
Label1.Text= "Venter på at output bliver dannet.";
Response.Write("<script>setTimeout('document.location.reload()', 1000);</script>");
}
}
catch
{
}
}
}
Showpdf.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ShowPdf.aspx.cs" Inherits="ShowPdf" UICulture="da-DK" %>
<!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" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label_time" runat="server" Text=""></asp:Label><p></p>
<script>
setTimeout("reloadpage()", 1000);
function reloadpage() { document.location.reload(); }
</script>
<asp:HyperLink ID="HyperLink1" visible=false runat="server">Klik her hvis pdf-filen ikke vises automatisk.</asp:HyperLink>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label><p></p>
<asp:Button ID="Button1"
runat="server" Text="Fortryd" OnClientClick="window.close()" />
</div>
</form>
<script>postLoad();</script>
</body>
</html>
Showpdf.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.IO;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ShowPdf : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label_time.Text= DateTime.Now.ToString();
try
{
string pdffilename = Request["id"];
string webname = "temp/" + pdffilename.Replace(".pdf","_.pdf");
string physName = Server.MapPath(webname);
if (System.IO.File.Exists(physName)) {
//Response.WriteFile(physName);
//Response.Write("<script>document.location.replace('temp/"+pdffilename+"');</script>");
//Response.Redirect("temp/" + pdffilename, true);
/*FileStream pdfStream = new FileStream(physName,FileMode.Open, FileAccess.Read);
Response.ContentType = "application/pdf";
MemoryStream memStream = new MemoryStream();
Response.AddHeader("content-length",
System.Convert.ToString(pdfStream.Length));
//Response.BinaryWrite(pdfStream.);
*/
HyperLink1.NavigateUrl = webname;
HyperLink1.Visible = true;
Response.Write("<script>function postLoad() { document.getElementById('" + HyperLink1.ClientID + "').click(); }</script>");
/*
Response.Clear();
Response.ContentType = "application/pdf";
Response.WriteFile(physName);
*/
} else {
Label1.Text= "Venter på at PDF-fil bliver dannet.";
Response.Write("<script>setTimeout('document.location.reload()', 1000);</script>");
}
}
catch
{
}
}
}
Har forsøgt at søge i alle filer, men kan ikke finde frem til hvor <div style="page-break-before:always"></div> skrives henne - bemærk at dette er en ældre sag og der er ikke tilknyttet css filer.