Search This Blog

Friday, April 25, 2014

Dynamically Merge equal verticle cell value by Jquery

Dynamically Merge equal  verticle cell value

        this jquery merge verticle cell value if value is same arrive 

    function MergeCell()
      {
        var Tbl_Cell = new Array();
              

                var i = 1;
              
              var Fst_Value= null;
                var rowspan_Count = 1;
              
                $(".tblclassname").find('tr').each(function () {

                  
                    var td_Text = $(this).find('td:nth-child(2)');

                    if (Fst_Value== null) {
                       Fst_Value= td_Text;
                    } else if (td_Text.text() == Fst_Value.text()) {
                      
                        td_Text.remove();
                        ++rowspan_Count;

                        Fst_Value.attr('rowspan_Count', rowspan_Count);
                     
                    } else {
                        
                        Fst_Value= td_Text;
                        rowspan_Count = 1;
                    }
                });
        }

Thursday, February 6, 2014

how to check date is valid or not with leap year

How to check Date is Valid or not with leap year validation


function CheckDate() {
            var Date = $('#<%= ddlDate.ClientID %>').val();
            var Month = $('#<%= ddlMonth.ClientID %>').val();
            var Year = $('#<%= ddlYear.ClientID %>').val();

            if (parseInt(Date) > 0) {
                txtDate = Month + '/' + Date + '/' + Year;
                var currVal = txtDate;
                if (currVal == '') {
                    alert('Invalid Date');
                    return false;
                }

                var rxDatePattern = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/; //Declare Regex
                var dtArray = currVal.match(rxDatePattern); // is format OK?

                if (dtArray == null) {
                    alert('Invalid Date');
                    return false;
                }

                //Date Format is  mm/dd/yyyy format.
                dtMonth = dtArray[1];
                dtDay = dtArray[3];
                dtYear = dtArray[5];

                if (dtMonth < 1 || dtMonth > 12) {
                    alert('Invalid Date');
                    return false;
                }
                else if (dtDay < 1 || dtDay > 31) {
                    alert('Invalid Date');
                    return false;
                }
                else if ((dtMonth == 4 || dtMonth == 6 || dtMonth == 9 || dtMonth == 11) && dtDay == 31) {
                    alert('Invalid Date');
                    return false;
                }
                else if (dtMonth == 2) {
                    var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0));
                    if (dtDay > 29 || (dtDay == 29 && !isleap)) {
                        alert('Invalid Date');
                        return false;
                    }
                }
                return true;
            }
            return true;
        }


Wednesday, February 5, 2014

check in sql record is exits or not

How to check in sql record is exits (available) ?



Here give the Example of User Name is already taken by other user ?

Create Proc CheckUserNameExits
      @UserName varchar(20),
      @Result varchar(50) output
AS
BEGIN


      IF EXISTS (Select ID From UserMaster Where UserName=@UserName )     
            BEGIN      
                  SET   Result= 'User Name Is already Exits'     
            END
      ELSE
            BEGIN      
                  SET @Result= 'User Name Is not Exits'     
            END
      END
     
END



How to Call this Stored Procedure

string strStatus = "";
            this.DataContext.spInsertInOutTimeFromLoginPage(UserID, type, ref strStatus, ExtraTime, Initials);
            return strStatus;

In strStatus you get output from your Stored Procedure

Note : strStatus must be pass with ‘ref’ keyword

Saturday, February 1, 2014

Jquery for Gridview text filter on keypress

On Key press Gridview row filter jquery



HTML : 


 Filter: <input name="filter" id="filter" value="" maxlength="30" size="20" style="height: 24px;"
                                                    type="text" placeholder="Filter" />

<asp:GridView ID="gv1" runat="server"  CssClass="gvPreJobList" >

JQuery : 

 $(document).ready(function () {

 $("#filter").keyup(function () {
                    if (this.value.trim() != "") {
                        var rows = $(".gvPreJobList").find("tr").hide();
                        $(".gvPreJobList").find("thead").find("tr").show();
                        var data = this.value.split(" ");
                        $.each(data, function (i, v) {
                            rows.filter(":contains('" + v + "')").show();
                        });
                    }
                    else {
                        var rows = $(".gvPreJobList").find("tr").show();
                    }
                });
        });

Decimal text only allow on keypress Jquery

Jquery for Only Decimal text allow in Textbox



HTML:


<asp:TextBox ID="txtAmount" runat="server" CssClass="amount" Width="50px"></asp:TextBox>


Jquery :


$(document).ready(function () {
             $(".amount").keydown(function (event) {
                        // Allow: backspace, delete, tab, escape, enter and .
                        if ($.inArray(event.keyCode, [46, 8, 9, 27, 13, 110, 119, 190]) !== -1 ||
                        // Allow: Ctrl+A
                            (event.keyCode == 65 && event.ctrlKey === true) ||
                        // Allow: home, end, left, right
                                (event.keyCode >= 35 && event.keyCode <= 39)) {
                            // let it happen, don't do anything
                            return;
                        }
                        else {
                            // Ensure that it is a number and stop the keypress
                            if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
                                event.preventDefault();
                            }
                        }
                    });
            });

Note : If you want only number not decimal then remove 190 key-code


Friday, January 17, 2014

Get Next upComing day of week on which date

If you want to get next upcoming day on which date

Get Next Coming Saturday day on which date


public static DateTime GetNextSaturdayDate(DateTime dtTodaysDate)
        {
            DateTime dtReturnDate = dtTodaysDate;
            if (dtReturnDate.DayOfWeek == DayOfWeek.Saturday) dtReturnDate = dtReturnDate.AddDays(1);

            while (true)
            {
                if (dtReturnDate.DayOfWeek == DayOfWeek.Saturday)
                    break;
                dtReturnDate = dtReturnDate.AddDays(1);
            }
            return dtReturnDate;
        }


Get Full Month Name in string from Date

Get Full Month Name in string from Date


public static string GetMonthName(DateTime YourDate)
        {
            var formatDate = new DateTimeFormatInfo();
            string[] Month_Name = formatDate.MonthNames;
            return Month_Name [YourDate.Month - 1];
        }

For use this import System.Globalization NameSpace

Thursday, January 9, 2014

Set menu active class dynamically by jquery

Set menu active class dynamically by jquery


We want to set  class=”active” dynamically to menu by jquery

<script type="text/javascript">

        $(document).ready(function () {

            var url = window.location.pathname;
            var activePage = url.substring(url.lastIndexOf('/') + 1);

            //For Main Menu

            $('#menu > li > a').each(function () {
                var currentPage = this.href.substring(this.href.lastIndexOf('/') + 1);

                if (activePage == currentPage) {
                    $(this).addClass('active');
                }
            });

            //For Inner Menu

            $('#menu > li ').each(function () {

                $('#menu > li > ul > li > a ').each(function () {
                    var currentPage = this.href.substring(this.href.lastIndexOf('/') + 1);
                    if (activePage == currentPage) {
                        $(this).addClass('active');
                        $(this).parent().parent().parent().children().addClass('active');
                    }
                });

            });
</script>

HTML Menu
<ul id="menu">
        <li><a href="”user.aspx”">Users</a>
            <ul>
                <li><a href=" user.aspx">Normal Users</a></li>
                <li><a href=" adminuser.aspx.aspx">Admin Users</a></li>
            </ul>
        </li>
        <li><a href="Products.aspx">Product</a>
            <ul>
                <li><a href="Products.aspx">Products</a></li>
                <li><a href="ProductCategory.aspx">Product Category</a></li>
            </ul>
        </li>
        <li><a href="ManagePurchaseOrders.aspx">Order
            </a></li>
        <li><a href="ManageBackOrders.aspx">BackOrder
            </a></li>
    </ul>



Asp.net Grid view render heading tag thead instead of tbody

Asp.net Grid view render heading  tag  <thead> instead of  <tbody>


Grid View Render in <thead> tag.

Create a function or event Like 

protected void GridView1_DataBound(object sender, EventArgs e)
        {
            if (GridView1.HeaderRow != null)
            {
                GridView1.UseAccessibleHeader = true;
                GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
        }


Still if you got any error like

Error:

The table  must contain row sections in order of header, body, then footer”

Problem : PagerSettings-Position="TopAndBottom"

Solution : PagerSettings-Position="Bottom"