метод POST

Скрыть

Показать

Копировать
  index.html  
<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8" />
 <title></title>
</head>
<body>
 <form action="abc.aspx" target="_blank" method="post">
  <input type="text" name="a" />
  <br />
  <br />
  <input type="text" name="b" />
  <br />
  <br />
  <input type="submit" name="go" value="GO" />
 </form>
</body>
</html>
Скрыть

Показать

Копировать
  abc.aspx  
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="abc.aspx.cs" Inherits="abc" %>
 
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
 <meta charset="utf-8" />
 <title></title>
</head>
<body>
 <form id="form1" runat="server">
  <div>
   <% Function(); %>
  </div>
 </form>
</body>
</html>
Скрыть

Показать

Копировать
  abc.aspx.cs  
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class abc : System.Web.UI.Page {
 int Result(string arg0, string arg1) {
  return (int.Parse(arg0) + int.Parse(arg1));
 }
 public void Function() {
  string a = Request.Form["a"];
  string b = Request.Form["b"];
  if(Request.HttpMethod == "POST") {
   //если была нажата кнопка GO
   if(Request.Form["go"] != null) {
    //если значения параметров метода POST пустые
    if(string.IsNullOrEmpty(a) & string.IsNullOrEmpty(b)) {
     Response.Write("");
    }
    else {
     Response.Write("<label>"+a+"</label>&nbsp;&nbsp;+&nbsp;&nbsp;<label>"+b+"</label>&nbsp;&nbsp;=&nbsp;&nbsp;<label>"+Result(a, b).ToString()+"</label>");
    }
   }
  }
 }
 protected void Page_Load(object sender, EventArgs e) {
 
 }
}