Skip to content

Instantly share code, notes, and snippets.

View vikas6962's full-sized avatar

Vikas Gupta vikas6962

  • Lucknow
View GitHub Profile
@vikas6962
vikas6962 / CustomFilter.cs
Created November 30, 2023 06:40
Custom Authorization filter with no back after logout
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace TestFilter.Filters
{
public class AuthorizationFilter : AuthorizeAttribute, IAuthorizationFilter
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
namespace UPNEDA
@vikas6962
vikas6962 / common.js
Created July 11, 2019 05:07
bind input box(type)
$(document).ready(function () {
$('.numericOnly').bind('keypress', function (e) {
if ((e.which < 48 || e.which > 57) && e.which != 46) {
if (e.which == 8 || e.which == 0) {
return true;
}
else {
return false;
}
@vikas6962
vikas6962 / AESEncrytDecry.cs
Created April 9, 2019 04:42
Two way encryption Decryption
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Security.Cryptography;
using System.IO;
namespace ClientsideEncryption
{
@vikas6962
vikas6962 / controller.cs
Created March 8, 2019 06:25
Export to excel (Dynamic header and column)
System.Web.Helpers.WebGrid grid = new System.Web.Helpers.WebGrid(source: model.lstAdmissionFeeModel, canPage: false, canSort: false);
string gridData = grid.GetHtml(
tableStyle: "table table-bordered example",
headerStyle: "bg-pink",
fillEmptyRows: false,
columns: grid.Columns(
// grid.Column(header: "S.No.", format: item => item.WebGrid.Rows.IndexOf(item) + 1 + Math.Round(Convert.ToDecimal(grid.TotalRowCount / grid.PageCount) / grid.RowsPerPage) * grid.RowsPerPage * grid.PageIndex, canSort: true),
grid.Column("Program", header: "Program"),
grid.Column("StudentID", header: "StudentID"),
grid.Column("StudentName", header: "StudentName"),
@vikas6962
vikas6962 / dataTables.bootstrap.min.js
Created December 18, 2018 05:00
Pagination in webgrid
/*!
DataTables Bootstrap 3 integration
©2011-2015 SpryMedia Ltd - datatables.net/license
*/
(function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(a){return b(a,window,document)}):"object"===typeof exports?module.exports=function(a,d){a||(a=window);if(!d||!d.fn.dataTable)d=require("datatables.net")(a,d).$;return b(d,a,a.document)}:b(jQuery,window,document)})(function(b,a,d,m){var f=b.fn.dataTable;b.extend(!0,f.defaults,{dom:"<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-5'i><'col-sm-7'p>>",renderer:"bootstrap"});b.extend(f.ext.classes,
{sWrapper:"dataTables_wrapper form-inline dt-bootstrap",sFilterInput:"form-control input-sm",sLengthSelect:"form-control input-sm",sProcessing:"dataTables_processing panel panel-default"});f.ext.renderer.pageButton.bootstrap=function(a,h,r,s,j,n){var o=new f.Api(a),t=a.oClasses,k=a.oLanguage.oPaginate,u=a.oLanguage.oAria.paginate||{},e,g,p=0,q=function(d,f){var l,h,i,c,m=function(a){a.preventDefault();!b(a.curre
@vikas6962
vikas6962 / controller.cs
Created December 17, 2018 04:41
Hold List in tempdata
public JsonResult GetColSubjectByCourse(int courseId)
{
TransactionConnection objTcon = new TransactionConnection();
var subList = objTcon.getAllSubjectByCourse_College<Subject>(courseId, Convert.ToInt32(SessionManager.CollegeCode)).ToList();
TempData["subjectList"] = subList;
return Json(subList, JsonRequestBehavior.AllowGet);
}
public JsonResult GetColOptSubjectByCourse(string group)
{
@vikas6962
vikas6962 / Report.js
Created October 12, 2018 07:33
Export To Excel Using Angular JS
var app = angular.module("ROReport1", ['ui.bootstrap']);
app.controller("ReportRollListFinalController", function ($scope, $http, $location, $document, Excel, $timeout) {
$scope.CollegeCode = $document[0].getElementById("CollegeCode").value;
loadCollegeList();
var heading = '';
function loadCollegeList() {
var Collegeid = '0';
if ($scope.CollegeCode != "CSJMU") {
Collegeid = $scope.CollegeCode;
}
@vikas6962
vikas6962 / HomeController.cs
Last active October 12, 2018 05:44
Export To Excel
public ActionResult ExportToExcelRegColStudent(int CId)
{
studentBasicCollegeDetails model = new studentBasicCollegeDetails();
CollegeConnection objcolcon = new CollegeConnection();
model.StuList = objcolcon.getCollegeStudentListForExcel(CId, 2).ToList();
System.Web.Helpers.WebGrid grid = new System.Web.Helpers.WebGrid(source: model.StuList, canPage: false, canSort: false);
string gridData = grid.GetHtml(
tableStyle: "table table-bordered example",
@vikas6962
vikas6962 / test
Last active February 3, 2018 11:59
Angular keys and Methods
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="">
--print only when input contains "amit"--
<p>Input something in the input box:</p>
<p>Name : <input type="text" ng-model="name" placeholder="Enter name here"></p>
<h1 ng-if="name.includes('amit')">Hello {{name}}</h1>