Posts

How to add or update query string parameter to current url in Javascript

  In this post, I will let you know how to add or update query string parameter to current URL using Javascript. function  updateQueryStringParameter(uri, key, value) {          var  re =  new  RegExp( "([?&])"  + key +  "=.*?(&|$)" ,  "i" );          var  separator = uri.indexOf( '?' ) !== -1 ?  "&"  :  "?" ;          if  (uri.match(re)) {            return  uri.replace(re,  '$1'  + key +  "="  + value +  '$2' );         }          else  {            return  uri + separator...

Set date format in MVC/.Net Core using unobtrusive js

We will include some js for validation . @Scripts . Render ( "~/Scripts/jquery-3.1.1.js" ) @Scripts . Render ( "~/Scripts/jquery.validate.min.js" ) @Scripts . Render ( "~/Scripts/jquery.validate.unobtrusive.min.js" ) @Scripts . Render ( "~/Scripts/moment.js" ) we need moment.js so we will install or add put moment js file in out solution. And then we will finally add fix for date format parser in any js call after unobtrusive and page load $( function  () {     $.validator.methods.date = function  (value, element) {          return   this .optional(element) || moment(value, "DD / MMYYYY" , true ).isValid();     }}); I have set date format “dd/MM/yyyy”. moment js need date format in upper case so I have use as “DD/MMM/YYYY”.

Calculate Dynamic Current Calendar / Financial Year In C#

I need a financial / calendar year based on current or today's date time We need some time dynamically financial year or calendar year base on current date. Suppose any company or organization have calendar year like 1 st  Jan to 31 th  Dec, 1 st  Feb to 31 th  Jan, 1 st  Apr to 31 Mar, 1 st  Oct to 31 th  Sep etc...… So we need calculate current calendar year base on calendar start month of organization /company. Examples Suppose Today's date is 5 th  Feb 2017 and organization calendar start month is Jan(01) then current calendar year we will be 1 st  Jan 2017 to 31 th  Dec 2017. Suppose Today's date is 10 th  Mar 2017 and organization calendar start month is Apr(04) then current calendar year we will be 1 st  Apr 2016 to 31 th  Mar 2017. Suppose Today's date is 10 th  May 2018 and organization calendar start month is Apr(04) then current calendar year we will be 1 s t Apr 2018 to 31 th  Mar 2019...

DataTable With entity framework

First of all we create all classes for read data table request into class DataTableColumn

Form submit resulting in “InvalidDataException: Form value count limit 1024 exceeded.” In ASP.NET Core

You can change the default formvalue limit using the   FormOptions . If you are using MVC, then you can create a filter and decorate on action where you want to extend this limit and keep the default for rest of the actions. namespace Filter {     using System;     using Microsoft.AspNetCore.Http.Features;     using Microsoft.AspNetCore.Mvc.Filters;     /// <summary>     /// Request Form Size Limit Attribute     /// </summary>     /// <seealso cref="System.Attribute" />     /// <seealso cref="Microsoft.AspNetCore.Mvc.Filters.IAuthorizationFilter" />     /// <seealso cref="Microsoft.AspNetCore.Mvc.Filters.IOrderedFilter" />     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]     public class RequestFormSizeLimitAttribute : Attri...

Html helper bynamic table bind for DataTable and generic list model

  Html Helper with DataTable   public   static   MvcHtmlString  ToHtmlTable( this   HtmlHelper  html,  DataTable  dataTable)        {             StringBuilder  tempTableSb =  new   StringBuilder ();             if  (dataTable !=  null  && dataTable.Rows.Count > 0)            {                tempTableSb.Append( "<table class='table table - responsive table - bordered'>" );                tempTableSb.Append( "<thead><tr>" );          ...

Bind Drop Down by Enums in mvc/ asp.net

First of all you create a enum calss and define enum like FontFamily     public   static   partial   class   Enums     { public   enum   FontFamily         {              ///   < summary >              ///  The undefined              ///   </ summary >             Undefined,              ///   < summary >              ///  The courier              ///   </ summary >     ...