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" 이메일 : <asp:TextBox ID="txtEmail" 홈페이지 : <asp:TextBox ID="txtHomepage" 제목 : <asp:TextBox ID="txtTitle" 내용 : <asp:TextBox ID="txtContent" runat="server" 인코딩 : <asp:RadioButtonList ID="lstEncoding" runat="server" <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" <br /> <asp:LinkButton ID="btnModify" runat="server" <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"]); } } } |
'.Net Project > ASP.NET 3.5 Sp1' 카테고리의 다른 글
41-9장 답변형 게시판(Delete) (0) | 2009.10.27 |
---|---|
41-8장 답변형 게시판(View) (0) | 2009.10.27 |
41-6장 답변형 게시판(List) (0) | 2009.10.27 |
41-5장 답변형 게시판(Write) (0) | 2009.10.27 |
40장 ASP.NET Web 로그인 컨트롤 (Login Name) (0) | 2009.10.15 |