Tag: ASP.NET

[HowTo] LINQ filter : Ignore accented letters (Diacritics) in string comparison ?

Here is a small extension method that will do the job (Warning : do not use for Linq To Sql): public static string RemoveDiacritics(this string text) { string formD = text.Normalize(NormalizationForm.FormD); StringBuilder sb = new StringBuilder(); foreach (char ch in formD) { UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(ch); if (uc != UnicodeCategory.NonSpacingMark) { sb.Append(ch); } } return […]

Could not load file or assembly ‘xxx.yyy’ or one of its dependencies…

Annoying message … if any… Could not load file or assembly ‘xxx.yyy’ or one of its dependencies. An attempt was made to load a program with an incorrect format. or in French : Impossible de charger le fichier ou l’assembly ‘xxx.yyy’ ou une de ses dépendances. Tentative de chargement d’un programme de format incorrect. Problem […]

[HowTo] Write Excel file to web page (aspx)

Writing an Excel file to the response object in ASP.NET is quite easy… This piece of code works with most of the files type… string YourFilename = “test.xlsx”; string path = Server.MapPath(YourPath + YourFilename); Response.ClearContent(); Response.AddHeader(“content-disposition”, “attachement;filename=” + YourFilename); // Ouvrir avec MSExcel Response.ContentType = “application/ms-excel”; // MSWord // Response.ContentType = “application/msword”; // Text // […]

Exposing an event handler as a control property

You need to expose it as full-blown event, not as property. Page parser in ASP.NET is then able to wire syntax On=”handler_method_name” into your event as listener. #region Event Handlers public delegate void OnAddressSavedHandler(object sender, AddressEventArgs e); public class AddressEventArgs : EventArgs { public Int64 AddressID; public AddressEventArgs(){ } public AddressEventArgs(Int64 val) { AddressID = […]

[HowTo] Use jQuery with Aspx UpdatePanel (datepicker Sample code inside)

As the update panel is going to reload the contents of the html. You’ll have to listen for the UpdatePanel to complete and recreate the datepicker. Here is a very basic sample. This doesn’t take into account multiple update panels on your page or potential memory leaks from not properly destroying your datepicker. Another thing […]