/
Visualize.aspx.cs
74 lines (62 loc) · 1.98 KB
/
Visualize.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Visualize : System.Web.UI.Page
{
private TextoArq txt = null;
private ArquivoBLL arquivo;
protected void Page_Load(object sender, EventArgs e)
{
// verifica qual o id passado para saber
// qual o texto que deve apresentar
string id = Request.QueryString["id"];
arquivo = new ArquivoBLL();
// Descarrega da Base de Dados o texto com o id passado na QueryString
txt = arquivo.getTexto(Convert.ToInt32(id));
// Altera o titulo da pagina
this.Title = "Web2Text : " + txt.Titulo;
// Altera titulo do texto em vizualizacao
LabelTitulo.Text = txt.Titulo;
// Altera conteudo da Area de texto
TextBox1.Text = txt.TextContent;
TextBox1.ReadOnly = true;
// Detalhes do texto
labelUser.Text = txt.User;
labelData.Text = txt.DataArq.ToString();
linkWWW.NavigateUrl = txt.Link;
dlButton.ToolTip = "Download";
}
protected void downloadFile()
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("content-disposition", "attachment; filename=ficheiro.txt");
Response.Flush();
Response.Write(TextBox1.Text);
Response.End();
}
protected void moveEdicao()
{
arquivo.moveToEdicao(Convert.ToInt32(Request.QueryString["id"]));
Response.Redirect("Edicao.aspx");
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
downloadFile();
}
protected void LinkDownload_Click(object sender, EventArgs e)
{
downloadFile();
}
protected void LinkEdit_Click(object sender, EventArgs e)
{
moveEdicao();
}
protected void edButton_Click(object sender, ImageClickEventArgs e)
{
moveEdicao();
}
}