Friday, August 21, 2009

jQuery: grab array foreach through

$("input[name=quantity]").each(function(i) { this.style.background = "#ffffff"; });

Thursday, August 13, 2009

Javascript event anywhere on page calls function

document.onkeypress = stopRKey;
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
if ((evt.keyCode == 13)) {
return false;
}
}
//not sure how javascript knows what "evt" is but it does.

Tuesday, August 11, 2009

How to do jquery postback using C#

simple and sweet C# function dont forget attribute.


[System.Web.Services.WebMethod]
public static string GetCustomerCreditCardInfo(string accountNumber)
{
System.Data.DataTable dt = Order.GetOrderHistoryByAccountId(int.Parse(acountNumber));
return "";
}

place this text in a jquery function

$.ajax({ type: "POST", url: "PosOrderEntry.aspx/GetCustomerCreditCardInfo", data: "{accountNumber : '" + accountId + "'}", contentType: "application/json; charset=utf-8", dataType: "json",
success: function(msg) {
if (msg.d == "") {
alert('nothing'); //failure
}
alert(msg.d); //success
}
});
//notice that the accountNumber has to have the same name as the c#function argument name