Posts

Showing posts from July, 2013

check radio button is checked using JQuery

Given a group of radio buttons: <input type="radio" id="radio1" name="radioGroup" value="1"> <input type="radio" id="radio2" name="radioGroup" value="2"> You can test whether a specific one is checked using jQuery as follows: if ($("#radio1").prop("checked")) { // do something } // OR if ($("#radio1").is(":checked")) { // do something } // OR if you don't have ids set you can go by group name and value // (basically you need a selector that lets you specify the particular input) if ($("input[name='radioGroup'][value='1']").prop("checked"))

C# Crop white space from around the image

This code will crop the image based on all white and transparent pixels from around the image public static Bitmap CropWhiteSpace(Bitmap bmp) { int w = bmp.Width; int h = bmp.Height; int white = 0xffffff; Func allWhiteRow = r => { for (int i = 0; i < w; ++i) if ((bmp.GetPixel(i, r).ToArgb() & white) != white) return false; return true; }; Func allWhiteColumn = c => { for (int i = 0; i < h; ++i) if ((bmp.GetPixel(c, i).ToArgb() & white) != white) return false; return true; }; int topmost = 0; for (int row = 0; row < h; ++row) { if (!allWhiteRow(row)) break; topmost = row; } int bottommost = 0; for (int row = h - 1; row >= 0; --row) { if (!allWhiteRow(row)) break; bottommost = row; } int leftmost = 0, rightmost = 0; for (int col = 0; col < w; ++col) { if (!allWhiteColumn(col)) break; leftmost = col; } for (int col =

A generic error occurred in GDI+. Outputting image to response output stream giving GDI+ error

Some format needs to be saved to a seekable stream. Using an intermediate MemoryStream will do the trick: using (Bitmap image = new Bitmap(context.Server.MapPath("images/stars_5.png"))) { using(MemoryStream ms = new MemoryStream()) { image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); ms.WriteTo(context.Response.OutputStream); } }

Using CASE Statements In A SQL UPDATE Query

user following CASE statement: UPDATE [account] SET balance = ( CASE WHEN ((balance - 10.00) < 0) THEN 0 ELSE (balance - 10.00) END ) WHERE id = 1

Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack. Crystal Report

Image
First, you have to check your ReportPath if is correct rpt.Load(Server.MapPath("crMembers.rpt"));