블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

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

Category

Recent Post

Recent Comment

Archive

2009. 10. 15. 11:52 .Net Project/ASP.NET 3.5 Sp1
반응형

 Upload/View.aspx

 <%@ Page Language="C#" AutoEventWireup="true"
        CodeFile="View.aspx.cs" Inherits="Upload_View" %>

<!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="lblNum" runat="server"></asp:Label><br />
        제목:
        <asp:Label ID="lblTitle" runat="server"></asp:Label><br />
        이름:<asp:Label ID="lblName" runat="server"></asp:Label><br />
        이메일:<asp:Label ID="lblEmail" runat="server"></asp:Label><br />
        홈페이지:<asp:Label ID="lblHomepage" runat="server"></asp:Label><br />
        작성일:<asp:Label ID="lblPostDate" runat="server"></asp:Label><br />
        조회수:<asp:Label ID="lblReadCount" runat="server"></asp:Label><br />
        IP주소:<asp:Label ID="lblPostIP" runat="server"></asp:Label><br />
        파일 :
        <asp:Label ID="lblFileName" runat="server" /><br />
        파일 :
        <asp:HyperLink ID="lnkFileName" runat="server"></asp:HyperLink><br />
        파일 :
        <asp:PlaceHolder ID="ctlFileName" runat="server"></asp:PlaceHolder>
        <br />
        내용:<asp:Label ID="lblContent" runat="server"></asp:Label><br />
        <br />
       
        <asp:Button ID="btnModify" runat="server"
                Text="수정" onclick="btnModify_Click" />
       
     <input type="button" id="btnDelete" value="삭제"
            onclick="location.href='Delete.aspx?Num=<%= Request["Num"] %>';" />
           
        <asp:Button ID="btnList" runat="server"
            Text="리스트" OnClientClick="location.href='List.aspx';return false;"
            onclick="btnList_Click" />
      </div>
    </form>
</body>
</html>


 Upload/View.Cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Upload_View : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(Request["Num"]))
        {
            Response.Write("잘못된 요청입니다");
            Response.End();
        }
        else
        {
            if (!Page.IsPostBack)
            {
                DisplayData();
            }
        }

    }
    private void DisplayData()
    {
        UploadEntity ue = new UploadEntity();
        UploadBiz ub = new UploadBiz();
        ue = ub.ViewUpload(Convert.ToInt32(Request["Num"]));

        // 각각의 컨트롤에 바인딩
        lblNum.Text = Request["Num"];
        lblName.Text = ue.Name;
        lblEmail.Text = ue.Email;
        lblTitle.Text = ue.Title;
        lblHomepage.Text = ue.Homepage;
        lblPostDate.Text = ue.PostDate.ToString();
        lblReadCount.Text = ue.ReadCount.ToString();
        lblPostIP.Text = ue.PostIP;

        // 인코딩에 따른 내용 표시
        string content = "";
        if (ue.Encoding.ToLower() == "text") // Text : 입력한 소스 그대로 화면에 출력
        {
            content = ue.Content.Replace("&", "&amp;").Replace("<", "&lt;")
                .Replace(">", "&gt;").Replace("\r\n", "<br />")
                    .Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
        }
        else if (ue.Encoding.ToLower() == "mixed") // Mixed : 태그처리 + 엔터처리
        {
            content = ue.Content.Replace("\r\n", "<br />");
        }
        else
        {
            content = ue.Content; // HTML : 태그처리
        }
        lblContent.Text = content;

        //[1]
        lblFileName.Text = String.Format
            ("<a href='Down.aspx?FileName={0}'>{0}</a> / 다운수 : {1}"
            , ue.FileName, ue.DownCount);
       
        //[2]
        lnkFileName.Text = ue.FileName;
        lnkFileName.NavigateUrl = String.Format
                  ("~/Upload/Down.aspx?FileName={0}", ue.FileName);
        
        //[3]
        //[a] 동적으로 하이퍼링크를 만들어서
        HyperLink lnk = new HyperLink();
        lnk.Text = ue.FileName.ToString();
        lnk.NavigateUrl = String.Format
             ("~/Upload/Down.aspx?FileName={0}", ue.FileName);
       
        //[b] 플레이스홀더 컨트롤에 추가
        ctlFileName.Controls.Add(lnk);
    }
    //수정
    protected void btnModify_Click(object sender, EventArgs e)
    {
        //수정 페이지로 이동
        Response.Redirect("Modify.aspx?Num=" + Request["Num"]);
    }
    //리스트
    protected void btnList_Click(object sender, EventArgs e)
    {
        //리스트 페이지로 이동
        Response.Redirect("List.aspx?Num=" + Request["Num"]);
    }
}







반응형
posted by Magic_kit