Search This Blog

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"