블로그 이미지
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

Category

Recent Post

Recent Comment

Archive

2009. 10. 27. 02:31 .Net Project/ASP.NET 3.5 Sp1
반응형
ReplyModify.aspx 

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

 

<!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:TextBox ID="txtName" 
                    runat
="server"></asp:TextBox><br />   

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

        홈페이지 : <asp:TextBox ID="txtHomepage" 
                    runat
="server"></asp:TextBox><br />

        제목 : <asp:TextBox ID="txtTitle"
                    runat
="server"></asp:TextBox><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:LinkButton ID="btnModify" runat="server"
             OnClick
="btnModify_Click">
수정</asp:LinkButton>&nbsp;

        <a href="View.aspx?Num=<%= Request["Num"] %>">취소</a><br />

        <asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>

    </div>

    </form>

</body>

</html> 


 ReplyModify.Cs
using System;

using Reply.Entity;

using Reply.Bsl;

 

public partial class Reply_Modify : 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()

    {

        ReplyEntity re = new ReplyEntity();

 

        ReplyBiz rb = new ReplyBiz();

 

        rb.SelectReplyByNum(Convert.ToInt32(Request["Num"]));

        re = rb.SelectReplyByNum(Convert.ToInt32(Request["Num"]));

 

        // 각각의 컨트롤에 바인딩

        txtName.Text = re.Name;

        txtEmail.Text = re.Email;

        txtTitle.Text = re.Title;

        txtHomepage.Text = re.Homepage;

        txtContent.Text = re.Content;

 

        // 예전 인코딩에 따른 라디오버튼 리스트 선택

        if (re.Encoding.ToLower() == "html")

        {

            lstEncoding.SelectedIndex = 1;

        }

        else if (re.Encoding.ToLower() == "mixed")

        {

            lstEncoding.SelectedIndex = 2;

        } 

    } 

    protected void btnModify_Click(object sender, EventArgs e)

    {

        // DB 저장

        ReplyBiz rb = new ReplyBiz();

        ReplyEntity re = new ReplyEntity();

 

        re.Num = Convert.ToInt32(Request["Num"]);

        re.Name = txtName.Text;

        re.Email = txtEmail.Text;

        re.Title = txtTitle.Text;

        re.Content = txtContent.Text;

        re.Password = txtPassword.Text;

        re.Encoding = lstEncoding.SelectedValue;

        re.Homepage = txtHomepage.Text;

       

        re.ModifyDate = DateTime.Now;

        re.ModifyIP = Request.UserHostAddress;

 

        int result = rb.UpdateReply(re);

        if (result == -1)

        {

            lblError.Text = "암호가 틀립니다.";

        }

        else

        {

            // 상세보기로 이동

            Response.Redirect("View.aspx?Num=" + Request["Num"]);

        }

    }

} 









반응형
posted by Magic_kit