This blog is moved to
http://amalhashim.wordpress.com

Thursday, June 18, 2009

jQuery Tips

Selectors:
Getting text box value
$(“#TextBoxId”).val();
Chang or set label text
$(“#LabelId”).text(“Your Text”);
Set control CSS “i.e td border width”
$(“#td_id”).css('border-width', '1px');


Animation:
Display DIV element with animation
$("#div-id").show("slow");
$("#div-id").hide("slow");


Swap Items between two lists
$(“#list1-id :selected”).remove().appendTo(“#list2-id”);

Ajax:
Passing parameters to asp.net web services
var prm1=”value”;
var prm2=2;
$.ajax({
type: "POST",
url: "/AjaxWebMethods.aspx/WebMethod ",
data: '{"parameter1":"' + prm1+ '”,"parameter1":"' + prm2+ '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
/*your code*/
},
error: function(err) { /*your code*/}
});
Look for data line

No comments: