This file contains hidden or 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
string nameValueString = "..." | |
NameValueCollection collection = HttpUtility.ParseQueryString(nameValueString); |
This file contains hidden or 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 col = new NameValueCollection() { { "a", "b" }, { "1", "2" } }; // collection initializer | |
var values = col.Cast<string>().Select(e => col[e]); // b, 2 | |
var str = String.Join(",", values); // "b,2" |
This file contains hidden or 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 HtmlString OrderedList(IEnumerable<string> items) | |
{ | |
var sb = new StringBuilder(); | |
var orderedList = new TagBuilder("ol"); | |
foreach (var item in items) | |
{ | |
var listItem = new TagBuilder("li"); | |
listItem.SetInnerText(item); | |
sb.AppendLine(listItem.ToString(TagRenderMode.Normal)); | |
} |
This file contains hidden or 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
class MyClass | |
{ | |
public int Id { get; set; } | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
//... | |
} | |
public static string GetPropertyIdAsList() | |
{ |
This file contains hidden or 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 ControllerBase : Controller | |
{ | |
protected WebsiteContext LocalDatabase = new WebsiteContext(); | |
protected override void Dispose(bool disposing) | |
{ | |
LocalDatabase.Dispose(); | |
base.Dispose(disposing); | |
} | |
} |
This file contains hidden or 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
bool isTest = Boolean.Parse(ConfigurationManager.AppSettings["appSettingValue"]); |
This file contains hidden or 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 byte[] ConvertHttpPostedFileToByteArray(HttpPostedFileBase rawUploadFile) | |
{ | |
byte[] uploadImage; | |
using (var ms = new MemoryStream()) | |
{ | |
rawUploadFile.InputStream.CopyTo(ms); | |
uploadImage = ms.ToArray(); | |
} | |
return uploadImage; | |
} |
This file contains hidden or 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
.field-validation-error | |
{ | |
color: #ff0000; | |
} | |
.field-validation-valid | |
{ | |
display: none; | |
} | |
.input-validation-error | |
{ |
This file contains hidden or 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 ActionResult Index() | |
{ | |
string action = RouteData.GetRequiredString("action"); | |
string controller = RouteData.GetRequiredString("controller"); | |
string appDataPath = Server.MapPath("~/app_data"); | |
string file = Path.Combine(appDataPath, controller + ".xml"); | |
var xpath = "//item[@action='" + action + "']"; | |
var item = XDocument.Load(file).XPathSelectElement(xpath); | |
if (item != null) | |
{ |
This file contains hidden or 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 bool UploadToServer(string pathToFile) | |
{ | |
bool failure = false; | |
if (!FileUpload1.FileName.ToLowerInvariant().EndsWith(".xml")) { | |
failure = true; | |
} | |
StreamReader reader = new StreamReader(FileUpload1.FileContent); | |
string xmlContent = reader.ReadToEnd(); | |
if (!xmlContent.TrimStart().StartsWith("<?xml")) { |