JQUERY code snippet
<html><
head><script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script><script type="text/javascript">$(document).ready(function () {$(
"#btnPost").click(function () {
var number1 = $("#txtNumber1")[0].value;
var number2 = $("#txtNumber2")[0].value;
var url = "Samples/Data/AddNumbers.aspx?Number1=" + number1 + "&Number2=" + number2;$.post(url,
function (data) {$(
"#txtResult")[0].value = data;});
});
});
</script></
head><
body><table><tr><td><span>Number1:</span></td><td><input type="text" id="txtNumber1" /></td></tr><tr><td><span>Number2:</span></td><td><input type="text" id="txtNumber2" /></td></tr><tr><td><span>Result:</span></td><td><input type="text" readonly="readonly" id="txtResult" /></td></tr></table><button id="btnPost">Add</button></
body></
html>
/* Code written in ASP.net page AddNumbers.aspx.cs file
using
System;using System.Collections.Generic;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace JQuerySamples.Samples.Data{
public partial class AddNumbers : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
int number1 = Convert.ToInt32(Request.QueryString["Number1"]);
int number2 = Convert.ToInt32(Request.QueryString["Number2"]);Response.Write(number1 + number2);
}
}
}