Skip to main content

Posts

Showing posts from May, 2007

Flaw with buttons in the GridView pager

For unknown reason the GridView pager in Numeric and NumericFirstLast modes does not take into consideration values of the PreviousPageText and NextPageText properties from the pager settings. Instead an ellipsis is shown. Of course, you may say that the buttons with the ellipsis implement a bit different functionality. Yes, they do. But the problem leaves - text on these buttons is not customizable. Sometimes it becomes problematic especially if your customer is too pernickety. To solve this flaw you can use next approach: GridView1.RowDataBound+=new GridViewRowEventHandler(GridView1_RowDataBound); protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Pager) { Table pagerTable = (Table)e.Row.Cells[0].Controls[0]; TableRow pagerRow = pagerTable.Rows[0]; PagerSettings pagerSettings = ((GridView)sender).PagerSettings; int cellsCount = pagerRow.Cells.Count; if (pagerSettings.Mo

Image-based CAPTCHA. Demo Project

Demo project that illustrates the idea of the image-based CAPTCHA . The code overview The proposed image-based CAPTCHA control works in such a way: a visitor sees a picture with a distorted part and he has to click elsewhere in the anomalous region boundaries. The point he clicks on will be marked with a red spot. The control fulfils a double functionality, it renders its HTML content and forms the picture itself. It has two child controls: an image, and a hidden field that serves to store coordinates of the visitor's chosen point. The image URL forms by adding the special parameter to the currently requested URL. When the request to this new URL comes, the control interrupts the usual process of page loading and writes the image as a byte array in the response. protected override void OnInit(EventArgs e) { if (HttpContext.Current.Request[queryKey] != null) DrawImage(); ..... } private void DrawImage() { Bitmap bitmap; //the image creation goes here

Image-based CAPTCHA

The brief overview of the most known implementations Carnegie Mellon's PIX CAPTCHA - the so called "naming images CAPTCHA" - the user sees a few pictures, and has to select a word that is appropriate to all the shown pictures. The main problem of this type of CAPTCHAs is misspelling while writing the answer, and synonyms for the answer-word (for example: dog, hound, pooch). In the described case, this is solved by means of transferring all the variants of the answer to the client side. Oli Warner's KittenAuth - in order to prove his humanity, the visitor has to select all animals of a specified species among the proposed pictures. But, the limited number of pictures allows to recreate the picture base manually. Microsoft's Asirra - in outline, it is similar to KittenAuth - the user has to distinguish cats from dogs - but, it works with an extremely large array of pictures (photos of homeless animals from the specialized site), and a reconstruction of the pictur