HTML+ASHX form Submission Sample

Source: Internet
Author: User
Tags bool httpcontext xmlns

  This article mainly introduces the concrete implementation of the Html+ashx form submission, the need of friends can refer to the following

1,sumbit form submission     WebForm1.aspx source:  code as follows: <%@ Page language= "C #" autoeventwireup= "true" codebehind= " WebForm1.aspx.cs "inherits=" NETFormDemo.ashx.WebForm1 "%>    <! DOCTYPE html>    <html xmlns= "http://www.w3.org/1999/xhtml" >  <head >  <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>  <title></title>  <script type=" Text/javascript ">    < /script>  </head>  <body>  <form id= "Form1" action= "Submitform.ashx" >  < div>  <input type= "Submit" value= "submitted"/>  </div>  </form>  </body>   </html>    SUBMITFORM.ASHX source code:  codes are as follows: using system;  using System.Collections.Generic;   using system.linq;  using system.web;    namespace netformdemo.ashx  { ///<summary& gt; ///SubmitForm's summary description  ///</SUMMARY>&NBSp public class submitform:ihttphandler  {    public void ProcessRequest (HttpContext context)   {  Context. Response.ContentType = "Text/plain";  context. Response.Write ("Hello World"); }    public bool isreusable  {  get  {  return false;& nbsp } } } }    2,ajax submit   htmlpage1.html source code:  the following: <! DOCTYPE html>    <html xmlns= "http://www.w3.org/1999/xhtml" >    <head>  < title></title>  <script src= "test1.js" type= "Text/javascript" ></script>  <script Src= "Jquery-1.4.min.js" type= "Text/javascript" ></script>  <script type= "Text/javascript" >   function Add (URL) {  var A = $ ("#a1"). Val ();  var B = $ ("#b1"). Val ();  $.ajax ({  URL: "Ashx/add . ashx?i= "+ A +" &j= "+ b,  data: {  num1:a,  num2:b },  dataType:" HTML ",  success: function (ResULT) { } }); }  </script>  </head>    <body>  <form id= " Form1 "runat=" Server ">  <input type=" Text id= "A1"/>  <input type= "text" id= "B1"/>  < Input type= "button" onclick= "Add ()"/>  <label id= "lb" ></label>  </form>  </ body>    </html>    ADD.ASHX source:  code is as follows: using system;  using system.collections.generic;  using system.linq;  using system.web;    namespace netformdemo.ashx& nbsp { ///<summary> ///Login's summary description  ///</summary>  public class login:ihttphandler  {    public void ProcessRequest (HttpContext context)   {  context. Response.ContentType = "Text/plain";  int-i = convert.toint32 (context. request.params["I"]);  int sec = Convert.ToInt32 (context. Request.params["J"]);    int res = the sec;  context. RespoNse. Write (RES);  context. Response.Write (' FDD ff ');   }    public bool isreusable  {  get  {  return false;  } }     } }   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.