Category: unpublished

Convert Html to Tiff

using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Text; using System.Windows; using System.Windows.Forms; using System.Windows.Media.Imaging; class Program { private static WebBrowser InitialiseBrowser(string source) { // create a hidden web browser, which will navigate to the page WebBrowser browser = new WebBrowser(); browser.ScrollBarsEnabled = false; // we don’t want scrollbars on our image browser.ScriptErrorsSuppressed… Read more →

How to run code from sql server in c#

How to run code from sql server in c# SqlCommand cmd = new SqlCommand(“select Developer from Stackoverflow where UserID=’786′ and Developer=’Sufiyan'”, con); if (con.State == ConnectionState.Closed) { con.Open(); } SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { string codeSnippet = reader[“CodeSnippet”].ToString(); dynamic script = CSScript.LoadCode(@” using System; using System.Windows.Forms; using System.Collections.Generic; using System.Data; using System.Windows.Forms; using System.Data.SqlClient; public class RunFromSqlServer {… Read more →

type safe enum extensions for MVC

extension method public static class EnumSelectList { public static IEnumerable GetList(this T thing) where T : IEnumerable { var result = from i in thing select new SelectListItem { Text = i.Value }; return result; } } new method on the type public static IEnumerable GetAll() { var list = ( from i in _instances select i.Value) .Cast(); return list;… Read more →

MVC

simple ajax controller (for countries etc) ajax (these are research notes) consuming WebApi with MVC consuming WebApi with MVC Dynamic content in MVC/Razor the following contains xml entries to get past razor runtime compilation errors of namespace not found: @Html.LabelFor(model => model.path.Value, “Path”) @Html.DropDownList(“Path”, new List { new SelectListItem { Text = TypeSafeEnum.a.Value, Value = TypeSafeEnum.a.Value }, new SelectListItem {… Read more →