Development (101)


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 […]




MVC Radiobutton group

In order to group a series of radiobutton and allow only one control of the group to be selectable we’ll have to set the same value for the “name” attribute on all controls of the group. In Vb.Net Code Snippet <div id="group1">     @Html.RadioButton("group1", False, New With {.class = "radioClass"})     @Html.RadioButton("group1", False, New With {.class = […]




From Asp.net Webforms to Asp.net MVC

I’ve been using MVC recently for a while now, both at work and on my own, I am really enjoying it, the implementation proposed by Microsoft is simple and effective and it sticks more to the nature of a web session(request/response) than the Webform model with all it’s page lifecycle, control events and so on.  […]




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 […]




Data bind simbols legend in Asp.Net

An overview for the code render blocks in Asp.Net : <%#   %>  –  to be used for databinding (es repeater rows etc). <% %>   – code render block, allow execution of inline expressio (es Response.Write(“something”); <%$ %>   – Expression used to bind external parameters. <%= %>  – Renders the content of the block. <%: %>  […]




SQL- Update one table from another with inner join

To use when there’s the need to update a table with values from another table using a column match (join). UPDATE TABLE1 SET Colum1 = T2.Column1 FROM TABLE1 T1 INNER JOIN TABLE2 T2 ON T1.MatchID = T2.MatchID




SQL – Remove chars from string

To be used when there’s the need or removing one or more chars from a record in a SQL table: UPDATE TableName SET ColumnName = replace( ColumnName, ‘”‘, ” ); — Remove commas UPDATE TableName SET ColumnName = replace( replace(ColumnName, ‘,’, ”), ‘”‘, ” ); — Remove multiple chars: comma and quotes




EF Code first with MVC 3 scaffholding.

Here’s a sample of Code first and the MVC 3 scaffholding in action, in order to run it you’ll need the MVC 3 Tools Update extension and the Nuget package for MvcScaffholding. The schema is pretty simple: Dowload the source code.




Fiddler with an Asp.net site.

Fiddler is an Http monitor and it is very handy when it comes to analyze the traffic from and to your computer or more specifically if you want to list the connections made from and to your Asp.net website. It can even log and decrypt HTTPS calls. Here’s a guide on how to get it […]




Simple Lucene.net wrapper

Lucene.net is an excellent framework for implementing full text search into an application. I wrote a small wrapper to allow an easier usage of the library, it uses attributes on the class members you want to store in order to provide a strongly typed way to access the index. You can read the article here […]