jquery (8)


String.Format in Jquery

  Code Snippet postcodeSelections += $.validator.format('<select size="4" name="{0}" id="{1}" tabindex="10" class="dropdownPostcodes">', postcodeSelectionsIdentifier, postcodeSelectionsIdentifier);




JQuery filtering an array of objects using a condition

The equivalent of a Linq.Where() in JQuery: var elem = $.grep(postcodeResults, function (n) { return n.Udprn == selectedOption; }); Next step will be using linqjs




jQuery filter()

Nice to use when in need of extract a subset from an array based on one or more clauses. The equivalent of the Where condition in Linq. In the below snippet we filter all the hidden fields with an Id starting with “hidden” and where the value is not empty: var allHiddenFields = $.find(‘input[id^=hidden]’);var allHiddenFieldsWithValue […]




JQuery select handling

A few snippets for when it comes to handle selectboxes: //find an option by value var foundOption = $(“#ddlPhoneCode option[value=’AS’]”); //get selected option var foundOption = $(“#ddlPhoneCode”).val(); //remove an option from the control $(“#ddlPhoneCode option[value=’AS’]”).remove(); //get values from multi-select var foundOptions = []; $(‘#ddlPhoneCode:selected’).each(function(i, selected){ foundOptions[i] = $(selected).text(); }); //select an option into the select […]




Simple Asp.net Jquery Ajax paging

Following a great post on Encosia here’s a an ajax powered repeater, that uses JTemplates, with paging and the chance of changing the page size, you can download the sources from here : http://dl.dropbox.com/u/3844758/BlogCode/JTemplates.zip.




Easy Jquery validation in Asp.net 4

With Asp.net 4 comes a new property named ClientIDMode wich allow us to take control over the control ID rendered client side. The property can be applied at: Page level, all the controls within page will maintain the same ID specified by the developer : <%@ Page Title=”” Language=”C#” MasterPageFile=”~/MyMaster.Master” CodeBehind=”NewFeature.aspx.cs” ClientIDMode=”Static”…. Control level , […]




Easy Asp.net ajax file upload

Here’s a simple way to get file uploading without the widraw of a postback: it is the asp.net implementation (with a few changes) of the following jQuery plugin. An image is uploaded and the form submitted. The submitted form is sent to a custom handler (ashx). The image is saved to a website folder and […]




Get ClientID of an Asp.net control in external js

$(“*[id$=’txtDateFrom’]”)