Posts

Showing posts from 2017

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 : Attribute, IAuthorizationFilter     {         /// <summary>         /// The form options         /// </summary>         private read

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>" );                 foreach  ( DataColumn  col  in  dataTable.Columns)                {                    tempTableSb.Append( "<th>"  + col.Caption +  "</th>" );                }                tempTableSb.Append( "</tr></thead><tbody>" );                 foreach  ( DataRow  row  in  dataTable.Rows)                {                    tempTableSb.Append( "<tr>" );                     foreach  ( var  cell  in  row.ItemArray)           

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 >             Courier,              ///   < summary >              ///  The helvetica              ///   </ summary >             Helvetica,              ///   < summary >              ///  The times new roman              ///   </ summary >             TimesNewRoman,              ///   < summary >              ///  The symbol              ///   </ summary >             Symbol         } }   C# Code convert FontFamily Enums in list type and convert into SelectListItem   List < SelectListItem > fontList =  new