블로그 이미지
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. 6. 18:35 .Net Project/ASP.NET 3.5 Sp1
반응형

   



    
    <div>    
    <h3>글쓰기 </h3>
     이름:
    <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 />
  
    인코딩 : <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 />
    <asp:Button ID="btnWrite" runat="server" Text="저장"
            onclick="btnWrite_Click" /> &nbsp
    <asp:Button ID="btnList" runat="server" Text="리스트"
            onclick="btnList_Click" /><br />
    </div>
    </form>
</body>
</html>


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class Basic_Write : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //txtName 텍스트박스에 포커스
        Page.SetFocus("txtName");

    }
    protected void btnWrite_Click(object sender, EventArgs e)
    {
        SqlConnection objcon = new SqlConnection
            (ConfigurationManager.ConnectionStrings
             ["connectionString"].ConnectionString);

        SqlCommand objcmd = new SqlCommand("WriteBasic", objcon);
        objcmd.CommandType = CommandType.StoredProcedure;

        objcmd.Parameters.AddWithValue("@Name", txtName.Text);
        objcmd.Parameters.AddWithValue("@Email", txtEmail.Text);
        objcmd.Parameters.AddWithValue("@Title", txtTitle.Text);
        objcmd.Parameters.AddWithValue("PostIP",
                                                       Request.UserHostAddress);
        objcmd.Parameters.AddWithValue("@Content", txtContent.Text);
        objcmd.Parameters.AddWithValue("@Password", txtPassword.Text);
        objcmd.Parameters.AddWithValue("@Encoding",
                                                            lstEncoding.SelectedValue);
        objcmd.Parameters.AddWithValue("@Homepage",
                                                                       txtHomepage.Text);

        objcon.Open();
        objcmd.ExecuteNonQuery(); //실행
        objcon.Close();

        btnList_Click(null, null); //리스트 페이지로 이동
    }
    protected void btnList_Click(object sender, EventArgs e)
    {
        //리스트 페이지로 이동
        Response.Redirect("List.aspx");
    }
}



반응형
posted by Magic_kit