Asp.net C# ( GET and POST)

index.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="project.WebForm1" %>

<!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" action="result.aspx" method="get">
        <div>
            <% Response.Write("Hello World"); %><br/>
            <input type="input" name="name" />
            <input type="submit" name="submit">
        </div>
    </form>
</body>
</html>

result.apsx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="result.aspx.cs" Inherits="project.WebForm2" %>

<% 
   Response.Write(Request.QueryString["name"]); // GET
   // Response.Write( Request["name"] );        // POST 
%>

發表迴響