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 allWhiteColumn = c => { for (int i = 0; i = 0; --row) { if (!allWhiteRow(row)) break; bottommost = row; } int leftmost = 0, rightmost = 0; for (int col = 0; col = 0; --col) { if (!allWhiteColumn(col)) break; rightmost = col; } if (rightmost == 0) rightmost = w; // As reached left if (bottommost == 0) bottommost = h; // As reached top. int croppedWidth = rightmost - leftmost; int croppedHeight = bottommost - topmost; if (croppedWidth == 0) // No border on left or right { leftmost = 0; croppedWidth = w; } if (croppedHeight == 0) // No border on top or bottom { topmost = 0; croppedHeight = h; } try { var target = new Bi...

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)

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"));