Posts

Dynamic Query in LINQ using Predicate Builder

IntroductionThis tutorial explain how to create dynamic query using LINQ, Using Predicate Builder  LINQ to SQL dynamic query and Query with Entity Framework is easy. This concept first implement by albahari DescriptionPredicate Builder is power full LINQ expression which is mainly used when too many search filter parameter is there for querying data by writing dynamic query expression. We can write query like Dynamic SQL.
To know more about predicate delegate visit Predicate Delegate How To Implement Predicate Builder Model
publicclass PatientInfo { publicint PatientID { get; set; } [Required] publicstring FirstName { get; set; } [Required] publicstring LastName { get; set; } [Required] [DataType(DataType.DateTime)] public Nullable<System.DateTime> BirthDate { get; set; } publicstring Gender { get; set; } publicstring PatientType { get; set; } publicstring InsuranceNumber { get; set; } …

Connect to TFS using C Sharp

Login using Google API with C#

Image
Introduction
In this article, we learn about how to login using Google OAuth 2.0 with C#(.NET) or Authenticate Google API in Dot Net.

DescriptionAs we know Google OAuth 2.0 requires ClientId and ClientSecret before we proceeding to further step. So, first of all, we have to generate ClientId and ClientSecret from Google Developer Console by creating credential or generating a credential for Web Application or from Native Application.
I hope you have google account already if not then first create one before proceeding further.
Step 1: Create Credential for OAuth App. Step 2: Select appropriate application type from available option.
Based on where we are using login with google account we can select an application type. Here I have use other which works for a console app, Web application hosted on localhost as well as on domain.
Step 3: Copy and save generate ClientId and Client Secret

Now, you have your ClientId and ClientSecret which will be used for authenticating with Google API using C#.

Javascript Tips and Tricks

Javascript Tips and Tricks Introduction In this article, we learn about import consideration while we are working with javascript.This information will help you to prevent most common mistake while development. JS tips and Tricks at one place. Description Quick tips Use === while comparing two variable instead of ==Remember undefined is not nullRemember javascript falsy value:   0, '', NaN, null, undefinedRemember javascript truthy value:   '0', 'any string', [] (Empty array), {} (Empty object), 0 (any non-zero number) Always declare all variables at the beginning of every scope "use strict"; In javascript to avoid unwanted bug due to a variable.Avoid global variable declarationReduce globals e.g var name='abc', isValid=false; Should be writen as var common={name:'abc', isValid:false};Always declare local variablesNever declare Number, String or Boolean Objects ( e.g. Never use: new Number(1), new String("abc"), new Boolean()…

Add Event To Dynamically Added Control

IntroductionSometimes in real world project we require that we can add html control dynamically to after page successfully rendered on browser. We also require to perform certain task such as register event based on requirement.
In this article we learn about how we can register event on html control which was added dynamically using jquery.

Two implement this type of demo first of all we require jQuery library you can download from Here.

Html Snippet:
<div class="container"> <div class="body-container"> <input id="btnNew" type="button" value="Add New Button" /> <ul class="parent-ul"></ul> </div> </div>JavaScript Snippet: $(function () { console.log("DOM is READy"); // button handler which is responsible for //adding new html control $('#btnNew').click(function () { var cnt = $('.parent-ul .item')…

How to access Session in javascript

IntroductionIn this article we learn about how we can access ASP.NET server side session variable or data in client side JavaScript. I have requirement for current user session variable in client side to perform some action based on user and its role.
Here are method or way to interact session variable in client side or in JavaScript.

1. Directly access session variable with mix code(Asp.net Server side)
as per the below code. //First way to access session console.log("UserId:" + '<%=Session["UserId"] %>'); console.log("UserRole:" + '<%=Session["UserRole"] %>'); 2. Fetch session value from HiddenField
To fetch session value from hidden field first we have to set session data in server side and then we can access stored hidden value data in client side javascript.
//Set session value to hidden field for access this value in jquery protected void setSessionToHiddenValue() { Session.Add("…

Asp.Net Utility Functions

IntroductionThis article contains most useful utility function for Asp.Net WebForm as well as Asp.Net MVC project. All this method is collected from Internet sources like stackoverflow so it will be useful to many developer to find all useful method at one place.
See listed below most useful functions
1. Replace all special character in input string with '-' characterThis method replace special characters using Regex function
public static string ReplaceSpecialChar(string input) { Regex rgx = new Regex("[^a-zA-Z0-9]"); input = rgx.Replace(input, "-"); return input; }2. Remove all special characters from stringThis method remove all special characters and prepare new string which contains alpha numeric character along with underscore and space. public static string RemoveSpecialCharacters(string str) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < str.Length; i++) { if…

Learn More