블로그 이미지
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. 27. 02:28 .Net Project/ASP.NET 3.5 Sp1
반응형
Reply Write.aspx 

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

 

<!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>

        <h3><asp:Literal ID="ltrTitle" runat="server"
                
 Text="
쓰기"></asp:Literal></h3>

        <div>

            이름:

            <asp:TextBox ID="txtName" runat="server" /><br />

            이메일:

            <asp:TextBox ID="txtEmail" runat="server" /><br />

            홈페이지:

            <asp:TextBox ID="txtHomepage" runat="server" /><br />

            제목:

            <asp:TextBox ID="txtTitle" runat="server" /><br />

            내용:

            <asp:TextBox ID="txtContent" runat="server"
                
TextMode="MultiLine" Columns="20" Rows="5">

            </asp:TextBox><br />

            인코딩:

            <asp:RadioButtonList ID="lstEncoding" runat="server"     
                RepeatDirection
="Horizontal"

                RepeatLayout="Flow">

              <asp:ListItem Selected="True">Text</asp:ListItem>

              <asp:ListItem>HTML</asp:ListItem>

              <asp:ListItem>Mixed</asp:ListItem>

            </asp:RadioButtonList>

                <br />

            비밀번호:

            <asp:TextBox ID="txtPassword" runat="server" 
                 TextMode
="Password"></asp:TextBox><br />

            <br />

            <asp:Button ID="btnWrite" runat="server"
               
 Text="
저장" Height="21px"

                onclick="btnWrite_Click" />

            <asp:HyperLink ID="btnList" runat="server"
               
 Text="
리스트" NavigateUrl="List.aspx" />

        </div>

    </div>

    </form>

</body>

</html> 


 Reply Write.Cs
using System;

using Reply.Entity;

using Reply.Bsl;

 

public partial class Reply_Write : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        // Mode=Reply 식으로 Mode값이 / 값이 아니라면, 답변하기 로직 적용

        if (!String.IsNullOrEmpty(Request["Mode"]))

        {

            ltrTitle.Text = "답변달기";

            btnWrite.Text = " 답변";

            if (!Page.IsPostBack)

            {

                DisplayData();

            }

        }

    }

 

    private void DisplayData()

    {

        // 부모글의 제목과 내용을 텍스트박스에 바인딩

        ReplyEntity re = (new ReplyBiz()).SelectReplyByNum
                         (
Convert.ToInt32(Request["Num"]));

 

        this.txtTitle.Text = "Re : " + re.Title; // 부모글의 Re : 붙여서 출력

        this.txtContent.Text =

            "\r\n\r\n--------------------\r\n>" +

            re.Content.Replace("\r\n", "\r\n>")

            + "\r\n--------------------\r\n";

    }

    protected void btnWrite_Click(object sender, EventArgs e)

    {

        ReplyEntity re = new ReplyEntity();

 

        re.Name = txtName.Text;

        re.Email = txtEmail.Text;

        re.Homepage = txtHomepage.Text;

        re.Title = txtTitle.Text;

        re.PostIP = Request.UserHostAddress;

        re.Content = txtContent.Text;

        re.Encoding = lstEncoding.SelectedValue;

        re.Password = txtPassword.Text;

       

        if (!String.IsNullOrEmpty(Request["Mode"]) && Request
                    [
"Mode"].ToLower() == "reply")

        {

          // 답변 로직 처리 : 두번째 매개변수가 부모글의 번호(ParentNUm) 저장

        (new ReplyBiz()).InsertReply(re, Convert.ToInt32(Request["Num"]));

        }

        else

        {

            // 저장 로직 처리

            ReplyBiz rb = new ReplyBiz();

            rb.InsertReply(re);

        }

         // 리스트로 이동

        string strJs = @"

            <script>alert('입력되었습니다.');
                    location.href='List.aspx';</script>

        ";

        Page.ClientScript.RegisterClientScriptBlock
                                      (
this.GetType(), "goList", strJs);

    }

} 




반응형
posted by Magic_kit