[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 694
  • Last Modified:

simple captcha codings

Error      1      The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)      D:\sam\Default.aspx.cs      15      9      D:\sam\
Error      2      The type or namespace name 'Graphics' could not be found (are you missing a using directive or an assembly reference?)      D:\sam\Default.aspx.cs      16      9      D:\sam\
Error      3      The best overloaded method match for 'System.Drawing.Graphics.FromImage(System.Drawing.Image)' has some invalid arguments      D:\sam\Default.aspx.cs      16      32      D:\sam\
Error      4      Argument '1': cannot convert from 'Bitmap' to 'System.Drawing.Image'      D:\sam\Default.aspx.cs      16      66      D:\sam\
Error      5      The name 'Color' does not exist in the current context      D:\sam\Default.aspx.cs      17      27      D:\sam\
Error      6      The name 'TextRenderingHint' does not exist in the current context      D:\sam\Default.aspx.cs      18      41      D:\sam\
Error      7      The type or namespace name 'Font' could not be found (are you missing a using directive or an assembly reference?)      D:\sam\Default.aspx.cs      20      9      D:\sam\
Error      8      The type or namespace name 'Font' could not be found (are you missing a using directive or an assembly reference?)      D:\sam\Default.aspx.cs      20      28      D:\sam\
Error      9      The name 'FontStyle' does not exist in the current context      D:\sam\Default.aspx.cs      20      45      D:\sam\
Error      10      The name 'Brushes' does not exist in the current context      D:\sam\Default.aspx.cs      34      52      D:\sam\
Error      11      The name 'ImageFormat' does not exist in the current context      D:\sam\Default.aspx.cs      37      44      D:\sam\

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Bitmap objBMP = new System.Drawing.Bitmap(60, 20);
        Graphics objGraphics = System.Drawing.Graphics.FromImage(objBMP);
        objGraphics.Clear(Color.Green);
        objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
        //' Configure font to use for text
        Font objFont = new Font("Arial", 8, FontStyle.Italic);
        string randomStr = "";
        int[] myIntArray = new int[5];
        int x;
        //That is to create the random # and add it to our string
        Random autoRand = new Random();
        for (x = 0; x < 5; x++)
        {
            myIntArray[x] = System.Convert.ToInt32(autoRand.Next(0, 9));
            randomStr += (myIntArray[x].ToString());
        }
        //This is to add the string to session cookie, to be compared later
        Session.Add("randomStr", randomStr);
        //' Write out the text
        objGraphics.DrawString(randomStr, objFont, Brushes.White, 3, 3);
        //' Set the content type and return the image
        Response.ContentType = "image/GIF";
        objBMP.Save(Response.OutputStream, ImageFormat.Gif);
        objFont.Dispose();
        objGraphics.Dispose();

    }
    protected void submitt_btn_Click(object sender, EventArgs e)
    {

    }
}

Open in new window

0
sunda2010
Asked:
sunda2010
1 Solution
 
Miguel OzSoftware EngineerCommented:
You need:
using System.Drawing   ;
using System.Drawing.Imaging;

and see how it goes
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now