블로그 이미지
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. 11. 2. 14:21 .Net Project/ASP.NET 3.5 Sp1
반응형
 View.aspx

 



<!-- BoardView.aspx -->
<%@ Page Language="C#" AutoEventWireup="true"
    CodeFile="BoardView.aspx.cs"
    Inherits="DotNetNote_BoardView" %>

<!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>
  <link href="../DotNetNote/DotNetNote.css"
    rel="stylesheet" type="text/css" />
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <h3>완성형 게시판</h3>
      <font style="font-size: 9pt; color: #ff0000">
        글 보기 - 현재 글에 대해서 수정 및 삭제를 할 수
        있습니다. </font>
      <hr width="100%" size="1" />
      <table id="Table2" style="width: 740px;
        border-collapse: collapse; height: 352px"
        bordercolor="black" cellspacing="0"
        rules="none" width="740" align="center"
        bgcolor="white">
        <tbody>
          <tr style="color: white" bgcolor="#46698c"
            height="23">
            <td align="right" height="35">
              <b style="font-size: 18px">제&nbsp;&nbsp;
                목</b> :
            </td>
            <td width="640">
              <asp:Label ID="lblTitle" Font-Bold="True"
                Font-Size="18px" Width="100%"
                runat="server"></asp:Label></td>
          </tr>
          <tr bgcolor="#efefef">
            <td align="right">
              번&nbsp; 호 :
            </td>
            <td width="500">
              <asp:Label ID="lblNum" Width="84"
                runat="server"></asp:Label></td>
          </tr>
          <tr bgcolor="#efefef">
            <td align="right">
              이&nbsp; 름 :
            </td>
            <td width="500">
              <asp:Label ID="lblName" Width="100%"
                runat="server"></asp:Label></td>
          </tr>
          <tr bgcolor="#efefef">
            <td align="right">
              E-mail :
            </td>
            <td>
              <asp:Label ID="lblEmail" Width="100%"
                runat="server"></asp:Label></td>
          </tr>
          <tr bgcolor="#efefef">
            <td align="right">
              Homepage :
            </td>
            <td>
              <asp:Label ID="lblHomepage" Width="100%"
                runat="server"></asp:Label></td>
          </tr>
          <tr bgcolor="#efefef">
            <td align="right">
              작성일 :
            </td>
            <td>
              <asp:Label ID="lblPostDate" Width="100%"
                runat="server"></asp:Label></td>
          </tr>
          <tr bgcolor="#efefef">
            <td align="right">
              조회수 :
            </td>
            <td>
              <asp:Label ID="lblReadCount" Width="100%"
                runat="server"></asp:Label></td>
          </tr>
          <tr bgcolor="#efefef">
            <td align="right">
              IP 주소 :
            </td>
            <td>
              <asp:Label ID="lblPostIP" Width="100%"
                runat="server"></asp:Label></td>
          </tr>
          <tr bgcolor="#efefef">
            <td align="right">
              파일 :
            </td>
            <td>
              <asp:Label ID="lblFile" Width="100%"
                runat="server"></asp:Label></td>
          </tr>
          <tr>
            <td align="left" colspan="2" style="padding-right: 20px;
              padding-left: 20px; padding-bottom: 20px;
              padding-top: 20px">
              <asp:Literal ID="ltrImage" runat="server">
              </asp:Literal>
              <asp:Label ID="lblContent" runat="server"
                Width="100%" Height="115px"></asp:Label>
                <font face="굴림"><br />
                  <asp:Label ID="lblComment" runat="server"
                    Width="100%"></asp:Label></font>
            </td>
          </tr>
        </tbody>
      </table>
      <p align="center">
        <asp:Button ID="btnReply" runat="server"
          Width="51px" Height="19px" Text="답변"
          BorderStyle="Solid" BorderWidth="1px"
          BorderColor="Gray" OnClick="btnReply_Click">
        </asp:Button>&nbsp;&nbsp;<asp:Button
          ID="btnDelete" runat="server"
          Width="51" Height="19" Text="삭제"
          BorderStyle="Solid" BorderWidth="1px"
          BorderColor="Gray" CausesValidation="False"
          OnClick="btnDelete_Click"></asp:Button>&nbsp;&nbsp;
        <asp:Button ID="btnEdit" runat="server"
          Width="50px" Text="수정" BorderStyle="Solid"
          BorderWidth="1px" BorderColor="Gray"
          CausesValidation="False" OnClick="btnEdit_Click">
        </asp:Button><font face="굴림">&nbsp;&nbsp;&nbsp;
        </font>
        <asp:Button ID="btnList" runat="server"
          Width="50px" Text="목록보기" BorderStyle="Groove"
          BorderWidth="1px" BorderColor="Gray"
          CausesValidation="False" OnClick="btnList_Click">
        </asp:Button></p>
      <p align="center">
        <asp:Label ID="lblError" runat="server" ForeColor="Red"
          EnableViewState="False"></asp:Label></p>
    </div>
  </form>
</body>
</html>


 View.aspx.Cs

 using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
using System.Data.SqlClient;
using System.IO;

/// <summary>
/// BoardView : 완성형(DotNetNote) 게시판의 상세 페이지
/// </summary>
public partial class DotNetNote_BoardView : System.Web.UI.Page
{
  #region Private Member Variables
  private string strNum;//앞(리스트)에서 넘겨져 온 번호 저장
  #endregion

  #region Event Handlers
  //페이지 로드될 때 글 번호 받기
  protected void Page_Load(object sender, System.EventArgs e)
  {
    strNum = Request.QueryString["Num"];
    if (strNum == null)
    {
      Response.Redirect("./BoardList.aspx");
    }
    if (!this.IsPostBack)
    {
      ReadData();//넘겨져 온 번호에 해당하는 글만 읽어서 각 레이블에 출력
    }
  }

  // 삭제 페이지로 이동
  protected void btnDelete_Click(object sender, System.EventArgs e)
  {
    Response.Redirect("./BoardDelete.aspx?Num=" + strNum);
  }

  // 수정 페이지로 이동
  protected void btnEdit_Click(object sender, System.EventArgs e)
  {
    Response.Redirect("./BoardModify.aspx?Num=" + strNum);
  }

  // 리스트 페이지로 이동
  protected void btnList_Click(object sender, System.EventArgs e)
  {
    if (!String.IsNullOrEmpty(Request["SearchField"]) &&
      !String.IsNullOrEmpty(Request["SearchQuery"]))
    {
      Response.Redirect("BoardSearch.aspx?SearchField="
        + Request["SearchField"] + "&SearchQuery="
        + Request["SearchQuery"]);
    }
    Response.Redirect("./BoardList.aspx");
  }

  // 답변 페이지로 이동
  protected void btnReply_Click(object sender, System.EventArgs e)
  {
    Response.Redirect("BoardReply.aspx?Num=" + strNum);
  }
  #endregion

  #region Private Methods
  private void ReadData()
  {
    SqlConnection objCon = new SqlConnection();
    objCon.ConnectionString =
      ConfigurationManager.ConnectionStrings[
        "ConnectionString"].ConnectionString;
    objCon.Open();

    SqlCommand objCmd = new SqlCommand();
    objCmd.Connection = objCon;
    objCmd.CommandText = "ViewDotNetNote";
    objCmd.CommandType = CommandType.StoredProcedure;
    objCmd.Parameters.Add("@Num", SqlDbType.Int).Value = strNum;

    SqlDataReader objDr = objCmd.ExecuteReader();
    if (objDr.Read())
    {
      lblNum.Text = strNum;//번호
      lblName.Text = objDr["Name"].ToString();//이름
      lblEmail.Text =
        String.Format(
          "<a href='mailto:{0}'>{1}</a>",
          objDr["Email"].ToString(),
          objDr["Email"].ToString()
        );
      lblTitle.Text = objDr["Title"].ToString();
      string strContent = objDr["Content"].ToString();

      // 인코딩 방식에 따른 데이터 출력
      string strEncoding = objDr["Encoding"].ToString();
      if (strEncoding == "Text") // Text : 소스 그대로 표현
      {
        lblContent.Text =
          strContent.Replace("&", "&amp;").Replace(
            "<", "&lt;").Replace(">", "&gt;").Replace(
              "\r\n", "<br />");
      }
      else if (strEncoding == "Mixed") // Mixed : 엔터처리만
      {
        lblContent.Text =
          strContent.Replace("\r\n", "<br />");
      }
      else // HTML : HTML 형식으로 출력
      {
        lblContent.Text = strContent; // 변환없음
      }

      lblReadCount.Text = objDr["ReadCount"].ToString();
      lblHomepage.Text =
        String.Format(
          "<a href='{0}' target='_blank'>{1}</a>",
          objDr["Homepage"].ToString(),
          objDr["Homepage"].ToString()
        );
      lblPostDate.Text = objDr["PostDate"].ToString();
      lblPostIP.Text = objDr["PostIP"].ToString();
      if (objDr["FileName"].ToString().Length > 1)
      {
        lblFile.Text =
          String.Format("<a href='./BoardDown.aspx?Num={0}'>"
            + "{1}{2} / 전송수: {3}</a>",
            objDr["Num"].ToString(),
            "<img src='images/ext_zip.gif' border='0'>",
            objDr["FileName"].ToString(),
            objDr["DownCount"].ToString()
          );
        if (RedPlus.Library.Board.IsPhoto(
          objDr["FileName"].ToString()))
        {
          ltrImage.Text =
            String.Format(
              "<img src='ImageDown.aspx?FileName={0}'>",
              Server.UrlEncode(objDr["FileName"].ToString())
            );
        }
      }
      else
      {
        lblFile.Text = "(업로드된 파일이 없습니다.)";
      }
    }

    objDr.Close();
    objCon.Close();
  }
  #endregion
}



반응형
posted by Magic_kit