test3.aspx


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
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test3.aspx.cs" Inherits="FrmText.test3" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        아이디:
        <asp:TextBox ID="UserID" runat="server"></asp:TextBox><br />
        암호:
        <asp:TextBox ID="Password" runat="server"></asp:TextBox><br />
        이름:
        <asp:TextBox ID="Name" runat="server"></asp:TextBox><br />
        나이:
        <asp:TextBox ID="Age" runat="server"></asp:TextBox><br />
        <asp:Button ID="btnSubmit1" runat="server" Text="전송" OnClick="btnSubmit" />
    </div>
    </form>
</body>
</html>
 
cs



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
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace FrmText
{
    public partial class test3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string userid = "";
            string password = String.Empty;
            string name = "";
            string age = String.Empty;
 
            // Request 객체의 QueryString
            userid = Request.QueryString["UserID"];
            // Request 객체의 Params
            password = Request.Params["Passwod"];
            // Request 객체의 Form
            name = Request.Form["Name"];
            // Request 객체로 받기
            age = Request["Age"];
 
            string msg = String.Format(
                    "입력하신 아이디는 {0}이고 <br />"
                    + "암호는 {1} 입니다. <br />"
                    + "이름은 {2} 입니다. <br />"
                    + "나이는 {3} 입니다. <br />",
                    userid , password , name , age
                );
            Response.Write(msg);
        }
        protected void btnSubmit(object sender, EventArgs e)
        {
            string name = Name.Text;
            int age = Convert.ToInt16(Age.Text);
        }
    }
}
cs



입력해보면 아이디는 get이라고 출력이 안됩니다.  이유는 get방식이라 주소에 querystring 으로 날려줘야 합니다~




+ Recent posts