Steps:
1. First, use StringBuiler to "Draw" the required forms. Here, use StringBuider instead of using the + Code directly. You don't need to explain this problem.
2. dynamically splice the data in the involved text box ------ implement data persistence of user control
3. Add a hidden field to the form to indicate whether it is a sending-back process.
Use a simple code to sum two numbers.
Public class jsqHandler: IHttpHandler {
Public void ProcessRequest (HttpContext context ){
Context. Response. ContentType = "text/html ";
// Declare three Integer Variables
Int n1 = 0, n2 = 0, result = 0;
Bool ispostback = Convert. ToBoolean (context. Request. Form ["IsPostBack"]);
If (! Ispostback) // determine whether to load IsPostBack in aspx. cs for the first time.
{
// Obtain numbers 1 and 2 respectively
String sn1 = context. Request. Form ["txtNum1"];
String sn2 = context. Request. Form ["txtNum2"];
If (int. TryParse (sn1, out n1) & int. TryParse (sn2, out n2 ))
{
Result = n1 + n2;
}
Context. Response. Write (result. ToString ());
}
// Draw a form with a hidden field used to determine whether the process is sending back.
StringBuilder sbHtml = new StringBuilder ();
SbHtml. Append (". Append ("<input type = 'text' name = 'txtnum1 'value = '" + n1.ToString () + "'/> ")
. Append ("+ <input type = 'text' name = 'txtnum2 'value = '" + n2.ToString () + "'/> ")
. Append ("= <input type = 'text' name = 'txtresult 'value = '" + result. ToString () + "'/> ")
. Append ("<input type = 'ddd' name = 'ispostback' value = 'false'/> ")
. Append ("<br/> <input type = 'submit 'value = 'compute'/> ")
. Append ("</form> </body> ");
Context. Response. Write (sbHtml );
}
Public bool IsReusable {
Get {
Return false;
}
}
From wlitsoft