<%@ Page Language="VB" %>

<html>
<head>
<script>
var req;

function add() {
  var v1 = document.getElementById("txtValue1").value;
  var v2 = document.getElementById("txtValue2").value;
  var url = encodeURI("Add.aspx?v1=" + v1 + "&v2=" + v2);
  addCallBack(url);
}

function addCallBack(url) {
  req = getXMLHttpRequest();
  if (req) {
    req.onreadystatechange = addProcessReqChange;
    req.open("GET", url, true);
    req.send();
  }
}

function addProcessReqChange() {
  if (req.readyState == 4) {
    if (req.status == 200) {
      document.getElementById("txtAnswer").value = req.responseText;
    }
  }
}

function getXMLHttpRequest() {
  var x = null;
	if (typeof XMLHttpRequest != "undefined") {
		x = new XMLHttpRequest();
	} else {
		try {
			x = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				x = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			}
		}
	}
	return x;
}
</script>
</head>
<body>
    <form runat="server">
        <h3>Ajax2.aspx</h3>
        <asp:TextBox id="txtValue1" runat="server"></asp:TextBox>
        +
        <asp:TextBox id="txtValue2" runat="server"></asp:TextBox>
        <input onclick="add();" type="button" value== />
        <asp:TextBox id="txtAnswer" runat="server"></asp:TextBox>
    </form>
</body>
</html>
