This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install-Package EntityFramework | |
Update-Database -Verbose -Force | |
Enable-Migrations -EnableAutomaticMigrations -Force | |
Add-Migration //not compulsory | |
int | |
string | |
DateTime | |
byte[] for binary image | |
Guid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.mindstick.com/Articles/518b07f7-3fc8-4b86-8ab9-cab49ecb001a/ | |
//In View | |
<form action="@Url.Action("UploadPayment")" method="post" enctype="multipart/form-data"> | |
<input type="file" name="FileUploads" id="FileUploads1" /> | |
<input type="file" name="FileUploads" id="FileUploads2" /> | |
//In Model | |
public IEnumerable<HttpPostedFileBase> FileUploads { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Web.Mvc; | |
using System.Web; | |
using System.Collections.Generic; | |
namespace NPS.Helpers | |
{ | |
public static class HtmlPrefixScopeExtensions | |
{ | |
private const string idsToReuseKey = "__htmlPrefixScopeExtensions_IdsToReuse_"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
var grid = new WebGrid(Model.Select((item, index) => new { Index = index+1, Element = item }), defaultSort: "First Name", canSort: true, canPage: true, rowsPerPage: ViewBag.PageSize, ajaxUpdateContainerId: "grid"); | |
} | |
@grid.GetHtml(htmlAttributes: new { id = "grid" }, fillEmptyRows: false, tableStyle: "webGrid", headerStyle: "header", footerStyle: "footer", rowStyle: "rowcss", alternatingRowStyle: "alterrowcss", | |
selectedRowStyle: "selectedRow", | |
columns: grid.Columns( | |
grid.Column(columnName: "Index", header: "Sr No."), | |
grid.Column("Element.strSurnameEN", "Name", @<text><i data-val='@item.Element.ID'>@Convert.ToString(item.Element.strSurnameEN + " " + item.Element.strNameEN + " " + item.Element.strRelativeEN)</i></text> ), | |
grid.Column("Element.dtDOB", "DOB", item => item.Element.dtDOB != null ? item.Element.dtDOB.ToString("dd/MM/yyyy") : ""), | |
gri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the Real error off the ModelState | |
var errors = GetRealErrors(ModelState); | |
private IEnumerable<ModelError> GetRealErrors(IEnumerable<KeyValuePair<string, ModelState>> modelStateDictionary) | |
{ | |
var errorMessages = new List<ModelError>(); | |
foreach (var keyValuePair in modelStateDictionary) | |
{ | |
if (keyValuePair.Value.Errors.Count > 0) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String readableFileSized(long size) | |
{ | |
long bytes = size; | |
string[] suf = { "B", "KB", "MB", "GB", "TB", "PB" }; | |
int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024))); | |
double num = Math.Round(bytes / Math.Pow(1024, place), 1); | |
string readable = num.ToString() + suf[place]; | |
return readable; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataSet ds = new DataSet(); | |
ds.ReadXml(MapPath("MyXML.xml")); | |
GridView1.DataSource = ds; | |
GridView1.DataBind(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//File Upload | |
// If file field isn’t empty | |
if (filUpload.PostedFile != null) | |
{ | |
// Check file size (mustn’t be 0) | |
HttpPostedFile myFile = filUpload.PostedFile; | |
int nFileLen = myFile.ContentLength; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NumericComparer : System.Collections.IComparer | |
{ | |
public NumericComparer() | |
{ } | |
public int Compare(object x, object y) | |
{ | |
if ((x is string) && (y is string)) | |
{ | |
return StringLogicalComparer.Compare((string)x, (string)y); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void btnBackupWin_Click(object sender, RoutedEventArgs e) | |
{ | |
try | |
{ | |
if (_conSource != null && dgSource.Visibility==Visibility.Visible) | |
{ | |
var dialog = new System.Windows.Forms.FolderBrowserDialog | |
{ | |
Description = @"Select Folder to store backup file : " | |
}; |