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 : " | |
}; |
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
// How to set Style to All Same Type of Controls | |
<Window.Resources> | |
//GroupBox,TextBox,Button,Grid | |
//Set background Black of all GroupBox in current Window | |
<Style TargetType="{x:Type GroupBox}"> | |
<Setter Property="Background" Value="Black"/> | |
</Style> | |
</Window.Resources> | |
//Use of Radio Button |
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
<Window x:Class="temp.MainWindow" | |
xmlns:water="clr-namespace:temp" ... > | |
<Grid> | |
<TextBox Name="txtName" > | |
<water:WatermarkService.Watermark> | |
<TextBlock Text="Enter Your Name"/> | |
</water:WatermarkService.Watermark> | |
</TextBox> | |
</Grid> |