Wednesday, March 6, 2013

CSS Semi-transparent background

http://egilhansen.com/2011/10/21/css-trick-semi-transparent-css-background-works-all-browsers

Friday, July 13, 2012

Groovy: Parse through all xml files in a directory

def folder = <some folder path>
def baseDirectory = new File(folder)
def files = baseDirectory.listFiles().grep(~/.*xml$/)

for (file in files){
      //Do something with the file
}

Tuesday, July 10, 2012

Installing setuptools for Python2.7 on Windows

Assuming you have python 2.7 installed in C:\Python27
  1. Make sure your path includes C:\Python27\; and C:\Python27\Scripts\;
  2. Download setuptools-0.6c11.tar.gz and setuptools-0.6c11-py2.7.egg from here
  3. Extract the tar using 7zip into a folder outside C:\Python27 and copy the setuptools-0.6c11-py2.7.egg file into the extracted folder
  4. Open command prompt, get into the extracted folder and run the command: python ez_setup.py setuptool-0.6c11-py2.7.egg
You can now install modules like suds using the command
python setup.py install


Thanks to the guys at 

http://www.jansipke.nl/python-soap-client-with-suds/

Thursday, September 1, 2011

Passing arrays from jQuery to C# Webservice

Step 1:
Download json2.js from https://github.com/douglascrockford/JSON-js
Include in your <head>
<script type="text/javascript" src="scripts/json2.js"></script>


Step 2:
Assuming you are populating an array from a select list, create and populate an array

var Voltages = new Array();
// AddedVoltage is my select list
$("#AddedVoltage option").each(function () {
        Voltages.push($(this).val());
});

Step 3:
Convert your array to a json string using json2.js
var jsonString = JSON.stringify(Voltages)


Step 4:
You can now pass the jsonString in your ajax request and recieve it as a string in your webservice.

Step 5:
Download jayrock json from http://code.google.com/p/jayrock/downloads/detail?name=jayrock-0.9.12915.zip&can=2&q= and add reference to your .net project.
More info here (http://msdn.microsoft.com/en-us/library/bb299886.aspx)

Step 6:
You can now convert the received json string in your web service to a list using

public List<String> ConvertToList(string jsonString)
    {
        List<string> SelectedVoltages = new List<string>();
        using (JsonTextReader reader = new JsonTextReader(new StringReader(jsonString)))
        {
            while (reader.Read())
            {
                if (reader.TokenClass == JsonTokenClass.String)
                {
                    SelectedVoltages.Add(reader.Token.Text);
                }
            }
        }
        return SelectedVoltages;
    }



Wednesday, August 24, 2011

jQuery access textbox within GridView

If you want to access the textbox in the gridview example below, use
$("table[id*=ResultGridView] input[type=text][id*=date]")

<asp:GridView ID="ResultGridView" runat="server" OnRowDataBound="ResultGridView_RowDataBound">
       
<Columns>

           
<asp:TemplateField>

               
<ItemTemplate>

                   
<asp:TextBox ID="date" runat="server"></asp:TextBox>
dd/MM/yyyy                  </ItemTemplate>
           
</asp:TemplateField>

       
</Columns>

   
</asp:GridView>
 

Auto-resize textbox

Facebook like textboxes

Download this jquery plugin
http://james.padolsey.com/demos/plugins/jQuery/autoresize.jquery.js

Then apply this for your textbox

$('textarea#comment').autoResize({
    // On resize:
    onResize : function() {
        $(this).css({opacity:0.8});
    },
    // After resize:
    animateCallback : function() {
        $(this).css({opacity:1});
    },
    // Quite slow animation:
    animateDuration : 300,
    // More extra space:
    extraSpace : 40
});

Tuesday, August 9, 2011

ASP.net Submit does not work on enter press

Submit button wont get fired on press of Enter button on IE

<!-- Fix for IE bug submit on pressing "Enter") --> 
<div style="display:none">
           
<input type="text" name="hiddenText"/>
 
</div>