It's been a while, but it should be something like this I think.
//Read the information from the fields and pass it via Ajax to a webmethod.
//JQuery will block the raising of the click event of the button.
//1. Get all the parameters from the form.
var val1 = document.getElementById('clientid1').value;
var val2 = document.getElementById('clientid2').value;
var val3 = document.getElementById('clientid3').selectedIndex;
var val4 = document.getElementById('clientid4').options[index].innerHTML;
var val5 = document.getElementById('clientid5').innerHTML;
//2. put the parameters in a key/value pair like string
var datapropt = "{'val1':'" + val1 + "'";
datapropt += ", 'val2':'" + val2 + "'";
datapropt += ", 'val3':'" + val3 + "'";
datapropt += ", 'val4':'" + val4 + "'}";
//create function that will call the server side WebMethod
$.ajax({
type: "POST",
url: "StaticWebMethods.asmx/TheWebMethodName",
data: datapropt,
//cache: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
//alert(result + "");
location.reload(true);
}
});
the function in the StaticWebMethods.asmxfile would look similar to this:
[WebMethod]
public static bool TheWebMethodName(int val1, string val2, string val3, string val4){
//method body here
}
Hope this helps.
V.