Wednesday, 29 October 2014

ASP.NET CheckBoxList check and uncheck with jQuery

//

function SetFishingDay() {
                var txtval = $("#<%= txt_setday.ClientID %>").val();
                var $ctrls = $('#<%= chkdayoffishing.ClientID %>');
                var mm = '';
                //Uncheck all
                var selValuefalse = [1,2,3,4,5,6,7];              
                for (var i = 0; i < selValuefalse.length; i++) {
                    $ctrls.find('input:checkbox[value=' + selValuefalse[i] + ']').prop('checked', false);
                }

                //check selected
                var selValuetrue = [];
                for (var i = 0; i < txtval.length; i++) {
                    selValuetrue.push(txtval[i]);
                }
                var $ctrls = $('#<%= chkdayoffishing.ClientID %>');
                for (var i = 0; i < selValuetrue.length; i++) {
                    $ctrls.find('input:checkbox[value=' + selValuetrue[i] + ']').prop('checked', true);
                }

                return false;

            }

Wednesday, 8 October 2014

Pesudo class which is use with out using javascript class

There are a lot more Pseudo Class available through which we can really add special effects without using JavaScript. Below listed Pseudo Classes are some of the examples among those:
  1. :first-child
  2. :focus
  3. :hover
  4. :right
  5. :target
  6. :valid
  7. :visited
  8. :active
  9. :checked
  10. :default
  11. :dir()
  12. :disabled
  13. :empty 
  1. :enabled
  2. :first
  3. :root
  4. :scope
  5. :last-child
  6. :last-of-type
  7. :left
  8. :link
  9. :not()
  10. :nth-child()
  11. :only-child
  12. :first-of-type
  13. :fullscreen

  1. :only-of-type
  2. :optional
  3. :out-of-range
  4. :read-only
  5. :read-write
  6. :required
  7. :indeterminate
  8. :in-range
  9. :invalid
  10. :lang()
  11. :nth-last-child()
  12. :nth-last-of-type()
  13. :nth-of-type()
Note: Please check here for browser support details.

Thanks Smile | :) and I will be happy to head from you.

Monday, 6 October 2014

Select query with case using multiple when conditions to get Months from datetime columns

//Query

select CONVERT(date, Tally_VOUCHER.Date), CASE
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=4 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 1 else 2 end
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=5 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 3 else 4 end
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=6 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 5 else 6 end
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=7 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 7 else 8 end
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=8 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 9 else 10 end
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=9 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 11 else 12 end
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=10 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 13 else 14 end
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=11 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 15 else 16 end
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=12 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 17 else 18 end
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=1 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 19 else 20 end
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=2 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 21 else 22 end
  WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=3 then
  case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 23 else 24 end
   
END Month_Num

from Tally_VOUCHER



//Result

Dates               Month_Num
2013-10-31               14
2013-12-31               18
2013-11-29               16
2013-12-04               17
2013-04-25               2
2013-07-05               7
2013-07-31               8
2013-05-15               3
2013-08-27               10
2013-09-24               12
2013-11-04               15
2013-06-29               6
2013-05-31               4
2013-06-10               5
2013-09-01               11

Saturday, 27 September 2014

validate atleast on selection inside gridview using javascript




//Gridview

<asp:TemplateField >
 <ItemTemplate>
 <asp:CheckBox runat="server" ID="Chk_allCh" />
  </ItemTemplate>
 <HeaderTemplate>
 <asp:CheckBox runat="server" ID="Chk_all" onclick="checkAllRow(this);" />
</HeaderTemplate>

</asp:TemplateField>


//Script
function checkvalidateSelect() {
        var gridView = document.getElementById('<%=GridViewID.ClientID %>');
                    
                    var isValid = false;

                    for (var i = 1; i < gridView.rows.length; i++) {
                        var inputs = gridView.rows[i].getElementsByTagName('input');
                        if (inputs != null) {
                            if (inputs[0].type == "checkbox") {
                                if (inputs[0].checked) {
                                    isValid = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (!isValid) {
                 alert('Please select at least one');
                        return false;
                    }
                    else
                    { return true; }

                }         

Select/Unselect All inside griview with modal popup using javascript with Color selected rows


//Gridview

<asp:TemplateField >
 <ItemTemplate>
 <asp:CheckBox runat="server" ID="Chk_allCh" />
  </ItemTemplate>
 <HeaderTemplate>
 <asp:CheckBox runat="server" ID="Chk_all" onclick="checkAllRow(this);" />
</HeaderTemplate>
</asp:TemplateField>


//Script

function checkAllRow(objRef) {
       var GridView = objRef.parentNode.parentNode.parentNode.parentNode.parentNode;
       var inputList = GridView.getElementsByTagName("input");
       for (var i = 0; i < inputList.length; i++) {
           //Get the Cell To find out ColumnIndex
           var row = inputList[i].parentNode.parentNode;
           if (inputList[i].type == "checkbox" && objRef!= inputList[i]) {
              if (objRef.checked) {
       //If the header checkbox is checked//check all checkboxes//and highlight all rows
                 row.style.backgroundColor = "#5CADFF";
                 inputList[i].checked = true;
                }
           else {
       //If the header checkbox is checked//uncheck all checkboxes//and change rowcolor back to original
               if (row.rowIndex % 2 == 0) {
                //Alternating Row Color
                  row.style.backgroundColor = "#AED6FF";
                  }
                  else {
                   row.style.backgroundColor = "white";
                     }
                      inputList[i].checked = false;
                           }
                       }
                   }

               }

Compare between tow dates after converting using javascript

function Convet_CompareDates()
{
date1 = "11/06/2013";
date2 = "17/05/2013";
date1c = date1.split("/").reverse().join("-");
date2c = date2.split("/").reverse().join("-");
var datet1 = new Date(date1c);
var datet2 = new Date(date2c);
if(datet1>datet2)
{
alert('less');
}
else
{
alert('greater');
}
}

Saturday, 30 August 2014

Show javascript alert box italic, bold, underline etc


<!DOCTYPE html>
<html>
<body>

<script>

var txt = "Hello World!";

document.write("The original string: " + txt);

document.write("<p>Big: " + txt.big() + "</p>");
document.write("<p>Small: " + txt.small() + "</p>");

document.write("<p>Bold: " + txt.bold() + "</p>");
document.write("<p>Italic: " + txt.italics() + "</p>");

document.write("<p>Fixed: " + txt.fixed() + "</p>");
document.write("<p>Strike: " + txt.strike() + "</p>");

document.write("<p>Fontcolor: " + txt.fontcolor("green") + "</p>");
document.write("<p>Fontsize: " + txt.fontsize(6) + "</p>");

document.write("<p>Subscript: " + txt.sub() + "</p>");
document.write("<p>Superscript: " + txt.sup() + "</p>");

document.write("<p>Link: " + txt.link("http://www.w3schools.com") + "</p>");

document.write("<p>Blink: " + txt.blink() + " (does not work in IE, Chrome, Firefox or Safari)</p>");

</script>

</body>
</html>

Result

The original string: Hello World!
Big: Hello World!
Small: Hello World!
Bold: Hello World!
Italic: Hello World!
Fixed: Hello World!
Strike: Hello World!
Fontcolor: Hello World!
Fontsize: Hello World!
Subscript: Hello World!
Superscript: Hello World!
Link: Hello World!
Blink: Hello World! (does not work in IE, Chrome, Firefox or Safari)


Refferenc-
http://www.w3schools.com/jsref/jsref_italics.asp

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...