1
using System;
2
using System.Data;
3
using System.Web.UI;
4
using Microsoft.Practices.EnterpriseLibrary.Data;
5
6
public partial class Basic_ViewControl : System.Web.UI.UserControl
7
...{
8
protected void Page_Load(object sender, EventArgs e)
9
...{
10
// 넘겨져 온 쿼리스트링 값 검사
11
if (String.IsNullOrEmpty(Request["Num"]))
12
...{
13
Response.Write("잘못된 요청입니다.");
14
Response.End();
15
}
16
else
17
...{
18
if (!Page.IsPostBack)
19
...{
20
DisplayData(); // 출력 전담 메서드
21
}
22
}
23
}
24
private void DisplayData()
25
...{
26
using (IDataReader dr =
27
DatabaseFactory.CreateDatabase("ConnectionString")
28
.ExecuteReader("ViewBasic", Request["Num"]))
29
...{
30
while (dr.Read())
31
...{
32
각각의 컨트롤에 바인딩#region 각각의 컨트롤에 바인딩
33
lblNum.Text = dr["Num"].ToString();
34
lblTitle.Text = dr["Title"].ToString();
35
lblName.Text = dr["Name"].ToString();
36
lblEmail.Text = dr["Email"].ToString();
37
lblHomepage.Text = dr["Homepage"].ToString();
38
lblPostDate.Text = dr["PostDate"].ToString();
39
lblReadCount.Text = dr["ReadCount"].ToString();
40
lblPostIP.Text = dr["PostIP"].ToString();
41
#endregion
42
인코딩 방식에 따른 컨텐츠 출력#region 인코딩 방식에 따른 컨텐츠 출력
43
string strEncoding = dr["Encoding"].ToString();
44
if (strEncoding == "Text") // 태그 실행 방지/소스 그대로
45
...{
46
lblContent.Text =
47
dr["Content"].ToString().Replace(
48
"&", "&").Replace(
49
"<", "<").Replace(
50
">", ">").Replace(
51
"\r\n", "<br />").Replace(
52
"\t",
53
" ");
54
}
55
else if (strEncoding == "Mixed") // 태그 실행
56
...{
57
lblContent.Text = dr["Content"].ToString().
58
Replace("\r\n", "<br />");
59
}
60
else // HTML로 표시
61
...{
62
lblContent.Text = dr["Content"].ToString();
63
}
64
#endregion
65
}
66
}
67
}
68
protected void btnList_Click(object sender, EventArgs e)
69
...{
70
Response.Redirect("./List.aspx");
71
}
72
protected void btnModify_Click(object sender, EventArgs e)
73
...{
74
Response.Redirect("./Modify.aspx?Num=" + Request["Num"]);
75
}
76
protected void btnDelete_Click(object sender, EventArgs e)
77
...{
78
Response.Redirect("./Delete.aspx?Num=" + Request["Num"]);
79
}
80
}
81