Use a general handler to add 10px to the width and height of the div (and use the template page)

Source: Internet
Author: User

Respond

 

The procedure is as follows:

1. Create a general Handler

2. process the request (if it is the first time, it will be output directly, if it is a return request, it will receive the value and then output after processing)

3. Read the template page (skip this step if the template page is not used)

4. Replace Value

5. Response Request

1 using system; 2 using system. collections. generic; 3 using system. LINQ; 4 using system. web; 5 using system. text; 6 7 namespace _ 03div width and height plus 10px 8 {9 /// <summary> 10 /// divaddwdithandheigth abstract description 11 /// </Summary> 12 public class divaddwdithandheigth: ihttphandler13 {14 15 public void processrequest (httpcontext context) 16 {17 context. response. contenttype = "text/html"; 18 int Len = 0; 19 if (context. R Equest ["divlen"]! = NULL) 20 {21 Len = int. parse (context. request ["divlen"]) + 10; 22} 23 24 stringbuilder sb = new stringbuilder (); 25 sb. appendline ("<form method = 'get'>"); 26 Sb. appendline ("<Div style = 'width: @ lenpx; Height: @ lenpx; Border: 1px solid red; '>"); 27 sb. appendline ("</div>"); 28 sb. appendline ("<input type = 'ddd' name = 'didlen' value = '@ len'>"); 29 sb. appendline ("<input type = 'submit 'value = 'width and height plus 10px'>"); 30 sb. appendline ("</form>"); 31 string html = sb. tostring (); 32 html = html. replace ("@ len", Len. tostring (); 33 context. response. write (HTML); 34} 35 36 Public bool isreusable37 {38 get39 {40 return false; 41} 42} 43} 44}

 

 

The preceding steps are completed in a general processing program. The template page is used below.

Create template page

1 <! Doctype HTML> 2 <HTML xmlns = "http://www.w3.org/1999/xhtml"> 3 

In the browser, as shown below:

 

Create a general Handler

1 using system; 2 using system. collections. generic; 3 using system. LINQ; 4 using system. web; 5 using system. io; 6 using system. text; 7 8 namespace _ 01 Add 1 9 {10 /// <summary> 11 /// divaddwdithandheig2's abstract description 12 /// </Summary> 13 public class divaddwdithandheig22: ihttphandler14 {15 16 public void processrequest (httpcontext context) 17 {18 context. response. contenttype = "text/html"; 19 int Len = 0; 20 if (context. request ["divlen"]! = NULL) 21 {22 Len = int. parse (context. request ["divlen"]) + 10; 23} 24 string html = file. readalltext25 (26 path. combine27 (28 appdomain. currentdomain. basedirectory29, 30 "divaddwdithandheigth.html" 31) 32); 33 html = html. replace ("@ len", Len. tostring (); 34 context. response. write (HTML); 35} 36 37 public bool isreusable38 {39 get40 {41 return false; 42} 43} 44} 45}

After the request is processed

 

 

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.