ASP.NET Identity reset password

var Db = new ApplicationDbContext(); var userDetail = Db.Users.FirstOrDefault(u => u.UserName.Equals(Username)); String userId = userDetail.Id; String newPassword = “pa$$word”; ApplicationUser cUser = UserManager.FindById(userId); String hashedNewPassword = UserManager.PasswordHasher.HashPassword(newPassword); UserStore store = new UserStore(); cUser.PasswordHash = hashedNewPassword; UserManager.UpdateAsync(cUser); Db.SaveChanges();

UnitOfWork Generic Repository

The repository and unit of work patterns are intended to create an abstraction layer between the data access layer and the business logic layer of an application. Implementing these patterns can help insulate your application from changes in the data store and can facilitate automated unit testing or test-driven development (TDD). UnitOfwork public class UnitOfWork …

Export DataTable to Excel/CSV C#

protected void btnExport_Click(object sender, EventArgs e) { DataTable dtTable = new DataTable(); DataRow dtRow; dtTable.Columns.Add(“SNo”, typeof(int)); dtTable.Columns.Add(“Address”, typeof(string)); for (int i = 0; i <= 9; i++) { dtRow = dtTable.NewRow(); dtRow[0] = i; dtRow[1] = "Address " + i.ToString(); dtTable.Rows.Add(dtRow); } Response.ContentType = "Application/x-msexcel"; Response.AddHeader("content-disposition", "attachment;filename=test.csv"); Response.Write(ExportToCSVFile(dtTable)); Response.End(); } private string ExportToCSVFile(DataTable dtTable) { …

Dynamically create columns in a temp table and generate pivot report

Sample Data download: http://goo.gl/lcOf8z Generate excel report as below. Username, Address, City, State, Zip, Question 1, Question 2, Question 3, ….. Prakash, test, anand, gujarat, 388001, Answer 1, Answer 2, Answer 3,.. Chirag, test, anand, gujarat, 388001, Answer 1, Answer 2, Answer 3,.. SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO — ============================================= — Author: …

Add Comma into number using javascript

<script> addCommas = function(input){ // If the regex doesn’t match, `replace` returns the string unmodified return (input.toString()).replace( // Each parentheses group (or ‘capture’) in this regex becomes an argument // to the function; in this case, every argument after ‘match’ /^([-+]?)(0?)(\d+)(.?)(\d+)$/g, function(match, sign, zeros, before, decimal, after) { // Less obtrusive than adding ‘reverse’ method …

calling [Ajax.AjaxMethod()] not working

finally its resolved by using, <system.webServer> <validation validateIntegratedModeConfiguration=”false” /> <modules> <add name=”ScriptModule” preCondition=”integratedMode” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ /> </modules> <handlers> <remove name=”WebServiceHandlerFactory-Integrated” /> <add verb=”POST,GET” name=”Ajax” path=”ajax/*.ashx” type=”Ajax.PageHandlerFactory, Ajax” /> <add name=”ScriptHandlerFactory” verb=”*” path=”*.asmx” preCondition=”integratedMode” type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ /> <add name=”ScriptHandlerFactoryAppServices” verb=”*” path=”*_AppService.axd” preCondition=”integratedMode” type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ /> <add name=”ScriptResource” …

Android SDK Manager does not open in windows 8

I have installed windows 8 in my laptop and tried to open ‘Android SDK Manager’. It was not open. By googling I found the solution as below. Go to android-sdk folder what you had set path under windows->preference menu for android. Edit android.bat file. Find java_exe= And in front of add Java.exe path like “C:\Program …