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

'.Net Project/ASP.NET 3.5 Sp1'에 해당되는 글 117

  1. 2009.10.27 41-7장 답변형 게시판(Modify)
  2. 2009.10.27 41-6장 답변형 게시판(List)
  3. 2009.10.27 41-5장 답변형 게시판(Write)
  4. 2009.10.15 40장 ASP.NET Web 로그인 컨트롤 (Login Name)
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
2009. 10. 27. 02:30 .Net Project/ASP.NET 3.5 Sp1
반응형
 ReplyList.aspx

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

 

<!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>출력</h3>

        <div>

            <asp:GridView ID="ctlReplyList"
                              runat="server" AutoGenerateColumns="false">

                <Columns>

                    <asp:TemplateField HeaderText="제목">

                        <ItemTemplate>

                            <%# FuncStep(Eval("Step")) %>

                            <asp:HyperLink ID="lnkTitle" runat="server"

                        NavigateUrl='<%# "View.aspx?Num=" + Eval("Num") %>'>

                            <%# Eval("Title") %>

                            </asp:HyperLink>

                      <%# Reply.Common.Board.GetNewImg(Eval("PostDate")) %>

                        </ItemTemplate>

                    </asp:TemplateField>

                    <asp:BoundField HeaderText="Ref" DataField="Ref" />

                    <asp:BoundField HeaderText="Step" DataField="Step" />

              <asp:BoundField HeaderText="RefOrder" DataField="RefOrder" />

                </Columns>

                <EmptyDataTemplate>

                    <div>입력된 데이터 없습니다..</div>

                </EmptyDataTemplate>

            </asp:GridView>

            <asp:HyperLink ID="lnkWrite" runat="server"

                NavigateUrl="~/Reply/Write.aspx">글쓰기</asp:HyperLink>

        </div>

    </div>

    </form>

</body>

</html> 







반응형
posted by Magic_kit
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
2009. 10. 15. 13:50 .Net Project/ASP.NET 3.5 Sp1
반응형
Login Name 서버 컨트롤
- 인증 사용자의 이름을 보여줄 수 있다
-  LoginStatus 서버 컨트롤에서 생성하는 하이퍼 링크와 사용자 이름을 볼 수 있다.
Login Name.aspx
<%@ Page Language="C#" AutoEventWireup="true" 
                        
CodeFile="Default.aspx.cs" Inherits="_Default" %>

 

<!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>Login Name</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <asp:LoginView ID="LoginView1" runat="server">

            <AnonymousTemplate>

                <asp:LoginStatus ID="LoginStatus2" runat="server" />

                <asp:HyperLink ID="lnkRegister" runat="server" 
                     NavigateUrl
="~/Register.aspx">

                회원가입

                </asp:HyperLink>

            </AnonymousTemplate>

            <LoggedInTemplate>

                <asp:LoginStatus ID="LoginStatus1" runat="server" />

                <asp:HyperLink ID="lnkUserInfo" runat="server"
                                   NavigateUrl
="~/UserInfo.aspx">

                    <asp:LoginName ID="LoginName1" runat="server" />

                </asp:HyperLink>

            </LoggedInTemplate>

        </asp:LoginView>   

        <br />   

    </div>

    </form>

</body>

</html>






반응형
posted by Magic_kit