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> 

SQL truncate decimal points, Get only Date


SQL get only date and not time

For Ex: 12/07/2009 and not 12/07/2009 10:09:20...

convert(varchar(10),@YOUR_DATE,101)

SQL Remove decimal points

For Ex: 203.98 and not 203.98079
select cast((123.456-(123.456%.001)) as decimal (18,2))

Monday, August 1, 2011

Disabling ipv6 in Ubuntu

Installed netbeans on my Ubuntu 11.04 and it was failing to connect and install updates. Disabling ipv6 solved the issue.

Check status of ipv6
Terminal:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
0 means it's enabled and 1 - disabled

echo "#disable ipv6" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf

Done. Restart and check status of ipv6 again.

Cheers
Bhushan