Skip to content

Instantly share code, notes, and snippets.

View ankitkanojia's full-sized avatar
🤠
Adept Coder - Full Stack Developer

Ankit Kanojia ankitkanojia

🤠
Adept Coder - Full Stack Developer
View GitHub Profile
@ankitkanojia
ankitkanojia / sample.js
Last active September 2, 2019 07:08
Javascript or Jquery loop iterations, Different type of loop iterations.
var arrayCollection = [“ABC”, “DEF”, “HIJ”];
$.each(arrayCollection, function(index, value){
console.log(“index : “,index, “ value :”, value);
});
$(arrayCollection).each(function(index, value){
console.log(“index : “,index, “ value :”, value);
});
@ankitkanojia
ankitkanojia / helper.cs
Created September 2, 2019 05:50
Copy property function to copy all properties from one object to another using reflection
// Common function which is use to copy or make a clone of one object to another with datatype and value
public static void CopyProperties<TSelf, TSource>(this TSelf self, TSource source)
{
try
{
var sourceAllProperties = source.GetType().GetProperties();
foreach (var sourceProperty in sourceAllProperties)
{
var selfProperty = self.GetType().GetProperty(sourceProperty.Name);
@ankitkanojia
ankitkanojia / Test.cs
Created September 2, 2019 05:56
Send mail using send grid in c#
using YourProject.Helpers;
namespace YourProject.Controllers
{
public class HomeController : Controller
{
public void SendTestMail1620()
{
SendEmail.Send("EMAIL SUBJECT", "EMAIL TEMPLATE or CONTENT", "TO EMAIL");
@ankitkanojia
ankitkanojia / script.js
Created September 2, 2019 07:24
Call ajax from any platform using jquery library
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
function functionName(){
$.ajax({
type: "POST",
url: "URL",
data: '{parameterName: "' + parameterValue + '"',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
@ankitkanojia
ankitkanojia / Default.aspx.cs
Created September 2, 2019 08:04
call web method using ajax call in webform c#
using System;
using System.Collections.Generic;
using System.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
@ankitkanojia
ankitkanojia / App.jsx
Created September 3, 2019 03:46
API call in reactjs application using axios request
import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';
//install axios package using 'npm i axios' command
const axios = require('axios');
class App extends Component {
constructor(props) {
@ankitkanojia
ankitkanojia / App.jsx
Created September 3, 2019 03:47
API call in reactjs application using fetch request
import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
isLoading: true,
@ankitkanojia
ankitkanojia / App.js
Created September 13, 2019 10:43
React routing using package 'react-router-dom'
import React, {Component} from 'react';
import Header from './component/header';
import Main from './containers/main';
class App extends Component {
render() {
return (
<React.Fragment>
<Header />
<main className="container">
@ankitkanojia
ankitkanojia / Sample.html
Created September 17, 2019 06:04
Hight chart jquery plugin integration
<html>
<body>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-3d.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<div id="container" style="height: 400px;width:500px"></></div>
@ankitkanojia
ankitkanojia / Common.cs
Created January 27, 2020 17:14
Custom filter with search and previous/next functionality in MVC C#
//commoncode
public static CustomerModel GetData(int currentPage, string keyword)
{
int maxRows = 10;
var customerModel = new CustomerModel();
customerModel.Customers = new List<UserVm>();
var counter = 0;
var sqlQuery = string.Empty;
if(string.IsNullOrEmpty(keyword))
{