Wednesday, June 26, 2019

Export To Excel and Other In Jquery

1. Code of html

@{
    Layout = null;
}


<!DOCTYPE html>
<html>
<head>
    <title>jQuery TableExport Basic Demo</title> 
</head>
<body>
 
    <div class="container">
        <h1>jQuery TableExport Basic Demo</h1>
        <table id="tbl1" class="table table-striped table-bordered" data-name="cool-table">
            <caption class="btn-toolbar bottom">
                <button data-fileblob="{&quot;data&quot;:[[&quot;Rank&quot;,&quot;Country&quot;,&quot;Population&quot;,&quot;% of world population&quot;,&quot;Date&quot;],[&quot;1&quot;,&quot;China&quot;,&quot;1,370,570,000&quot;,&quot;18.9%&quot;,&quot;June 24, 2015&quot;],[&quot;2&quot;,&quot;India&quot;,&quot;1,273,140,000&quot;,&quot;17.6%&quot;,&quot;June 24, 2015&quot;],[&quot;3&quot;,&quot;United States&quot;,&quot;321,268,000&quot;,&quot;4.43%&quot;,&quot;June 24, 2015&quot;],[&quot;4&quot;,&quot;Indonesia&quot;,&quot;255,461,700&quot;,&quot;3.52%&quot;,&quot;July 1, 2015&quot;],[&quot;5&quot;,&quot;Brazil&quot;,&quot;204,503,000&quot;,&quot;2.82%&quot;,&quot;June 24, 2015&quot;],[&quot;6&quot;,&quot;Pakistan&quot;,&quot;190,156,000&quot;,&quot;2.62%&quot;,&quot;June 24, 2015&quot;]],&quot;fileName&quot;:&quot;myDownload&quot;,&quot;mimeType&quot;:&quot;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet&quot;,&quot;fileExtension&quot;:&quot;.xlsx&quot;}" class="btn btn-default xlsx">
                    Export to xlsx
                </button>
                @*<button data-fileblob="{&quot;data&quot;:[[&quot;Rank&quot;,&quot;Country&quot;,&quot;Population&quot;,&quot;% of world population&quot;,&quot;Date&quot;],[&quot;1&quot;,&quot;China&quot;,&quot;1,370,570,000&quot;,&quot;18.9%&quot;,&quot;June 24, 2015&quot;],[&quot;2&quot;,&quot;India&quot;,&quot;1,273,140,000&quot;,&quot;17.6%&quot;,&quot;June 24, 2015&quot;],[&quot;3&quot;,&quot;United States&quot;,&quot;321,268,000&quot;,&quot;4.43%&quot;,&quot;June 24, 2015&quot;],[&quot;4&quot;,&quot;Indonesia&quot;,&quot;255,461,700&quot;,&quot;3.52%&quot;,&quot;July 1, 2015&quot;],[&quot;5&quot;,&quot;Brazil&quot;,&quot;204,503,000&quot;,&quot;2.82%&quot;,&quot;June 24, 2015&quot;],[&quot;6&quot;,&quot;Pakistan&quot;,&quot;190,156,000&quot;,&quot;2.62%&quot;,&quot;June 24, 2015&quot;]],&quot;fileName&quot;:&quot;myDownload&quot;,&quot;mimeType&quot;:&quot;application/vnd.ms-excel&quot;,&quot;fileExtension&quot;:&quot;.xls&quot;}" class="btn btn-default xls">
                    Export to xls
                </button>
                <button data-fileblob="{&quot;data&quot;:&quot;\&quot;Rank\&quot;,\&quot;Country\&quot;,\&quot;Population\&quot;,\&quot;% of world population\&quot;,\&quot;Date\&quot;\r\n\&quot;1\&quot;,\&quot;China\&quot;,\&quot;1,370,570,000\&quot;,\&quot;18.9%\&quot;,\&quot;June 24, 2015\&quot;\r\n\&quot;2\&quot;,\&quot;India\&quot;,\&quot;1,273,140,000\&quot;,\&quot;17.6%\&quot;,\&quot;June 24, 2015\&quot;\r\n\&quot;3\&quot;,\&quot;United States\&quot;,\&quot;321,268,000\&quot;,\&quot;4.43%\&quot;,\&quot;June 24, 2015\&quot;\r\n\&quot;4\&quot;,\&quot;Indonesia\&quot;,\&quot;255,461,700\&quot;,\&quot;3.52%\&quot;,\&quot;July 1, 2015\&quot;\r\n\&quot;5\&quot;,\&quot;Brazil\&quot;,\&quot;204,503,000\&quot;,\&quot;2.82%\&quot;,\&quot;June 24, 2015\&quot;\r\n\&quot;6\&quot;,\&quot;Pakistan\&quot;,\&quot;190,156,000\&quot;,\&quot;2.62%\&quot;,\&quot;June 24, 2015\&quot;&quot;,&quot;fileName&quot;:&quot;myDownload&quot;,&quot;mimeType&quot;:&quot;text/csv&quot;,&quot;fileExtension&quot;:&quot;.csv&quot;}" class="btn btn-default csv">
                    Export to csv
                </button>
                <button data-fileblob="{&quot;data&quot;:&quot;Rank  Country  Population  % of world population  Date\r\n1  China  1,370,570,000  18.9%  June 24, 2015\r\n2  India  1,273,140,000  17.6%  June 24, 2015\r\n3  United States  321,268,000  4.43%  June 24, 2015\r\n4  Indonesia  255,461,700  3.52%  July 1, 2015\r\n5  Brazil  204,503,000  2.82%  June 24, 2015\r\n6  Pakistan  190,156,000  2.62%  June 24, 2015&quot;,&quot;fileName&quot;:&quot;myDownload&quot;,&quot;mimeType&quot;:&quot;text/plain&quot;,&quot;fileExtension&quot;:&quot;.txt&quot;}" class="btn btn-default txt">
                    Export to txt
                </button>*@
            </caption>
            <thead>
                <tr>
                    <th>Rank</th>
                    <th>Country</th>
                    <th>Population</th>
                    <th>% of world population</th>
                    <th>Date</th>
                    <th>Rank</th>
                    <th>Country</th>
                    <th>Population</th>
                    <th>% of world population</th>
                    <th>Date</th>
                    <th>Rank</th>
                    <th>Country</th>
                    <th>Population</th>
                    <th>% of world population</th>
                    <th>Date</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>

            </tbody>
        </table>

        <script src="/csjs/jquery-1.12.4.min.js"></script>
        <script src="/csjs/FileSaver.min.js"></script>
        <script src="/csjs/Blob.min.js"></script>
        <script src="/csjs/xls.core.min.js"></script>
        <script src="/csjs/tableexport.js"></script>
        <script>
            //$("#tbl1").tableExport({ formats: ["xlsx", "xls", "csv", "txt"], });
            $("#tbl1").tableExport({ formats: ["xlsx"] });
        </script>   

    </div> 
</body>
</html>


2.   Js File Link
https://drive.google.com/file/d/1cSpc7ZBUgsBXXURL3AwZD8W1C__XvWUR/view?usp=sharing

JS Files Link to download


3. Export To Excel and CSV but Import CSV only into DataTable

Monday, June 24, 2019

Set Default Value in property in c# or Set Value in property in c#

1. Using Constructor

class Person 
{
    public Person()
    {
        Name = "Default Name";
    }
    public string Name { get; set; }
}
2. Normal

private string name = "Default Name";
public string Name 
{
    get 
    {
        return name;
    }
    set
    {
        name = value;
    }
}

Action Filter in MVC

1.


     
    public class change_all_form_authorization : ActionFilterAttribute
    { 
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string controller_ = filterContext.RouteData.Values["controller"].ToString();
            string action_ = filterContext.RouteData.Values["action"].ToString();

            if (HttpContext.Current.Session["change_all_form_authorization"] == null)
            {
                HttpContext.Current.Session["change_all_form_authorization"] = "/" + controller_ + "/" + action_;
                //HttpContext.Current.Session["change_all_form_authorization"] = "authorize-form-password";
                filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new
                {
                    Controller = "Login",
                    Action = "auth_form_permi"
                }));
                //HttpContext.Current.Response.Redirect("/Login/auth_form_permi");
                return;
            }
            HttpContext.Current.Session["change_all_form_authorization"] = null;
            base.OnActionExecuting(filterContext);
        }
    }

Wednesday, June 19, 2019

Deploy or Publish

1. Local Hosting for Publish

2. Publish With Folder Option

3. Hosts File Path for Local hosting

4. Hosts Default File for local host,  Hash (#) Sign is for commented

5. Hosts File Change for Local Hosting


Async In MVC

1.  Async In MVC V start at

Web Api

1. Web Api Routing with Route , Passing parameter with [FromUri] or [FromBody]

Tuesday, June 18, 2019

Pass Checked Unchecked in checkbox mvc razor

1. Pass Checked Unchecked in checkbox in mvc razor
    or Pass Checked Unchecked in checkbox in mvc
    or Pass Checked Unchecked in checkbox in razor


<tbody>
    @for (int i = 0; i < dl.Count; i++)
    {
        <tr>
            <td>@(i + 1)<input type="hidden" name="forms_list[@(i)].formid" value="@fl[i].formid"></td>
            <td>@dl[i].form_name </td>
            <td><input type="checkbox" name="forms_list[@(i)].view_" value="true" @(dl[i].view_ == true ? "checked" : "unchecked")></td>
            <td><input type="checkbox" name="forms_list[@(i)].add_" value="true" @(dl[i].add_ == true ? "checked" : "unchecked") ></td>
            <td><input type="checkbox" name="forms_list[@(i)].edit_" value="true" @(dl[i].edit_ == true ? "checked" : "unchecked") ></td>
            <td><input type="checkbox" name="forms_list[@(i)].del_" value="true" @(dl[i].del_ == true ? "checked" : "unchecked") ></td>
        </tr>
    }
</tbody>

1. Pass disabled in mvc razor

<div class="col-1">
    <div class="form-group mb-3">
        <div class="custom-control custom-checkbox">
            <input type="checkbox" class="custom-control-input" id="Feb" name="Feb" checked="@Model.Feb" value="true" @(Model.Feb == true ? "disabled" : "")>
            <label class="custom-control-label" for="Feb">Feb</label>
        </div>
    </div>
</div>
<div class="col-1">
    <div class="form-group mb-3">
        <div class="custom-control custom-checkbox">
            <input type="checkbox" class="custom-control-input" id="Mar" name="Mar" checked="@Model.Mar" @(Model.Mar == true ? "disabled" : "") value="true">
            <label class="custom-control-label" for="Mar">Mar</label>
        </div>
    </div>
</div>

When web application with sql server connection using sql client, working in visual studio but not working in localhost as in iis

Error:  The EXECUTE permission was denied on the object 'StoredProcedureTest1', database 'testDb1', schema 'dbo'.  C...