I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
Image captcha is used for human verification. Actually some bots machine is used for creating back links to the blog/website. If you want to stop that machine, create human verification captcha. There are two types, first one is string based and another one is numbered based captcha. In this example, i will implement number based captcha.
Learn, how to design numbered based captcha. Actually, we will write some randomly generated number on image. After that we compare that number with the text box.
Video Contain Full code implementation details:
private void createcaptcha()
{
Random r1 = new Random();
number = r1.Next(10, 1000);
Image img = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
var font = new Font("TimesNewRoman", 25, FontStyle.Bold, GraphicsUnit.Pixel);
var graphics = Graphics.FromImage(img);
graphics.DrawString(number.ToString(), font, Brushes.Red, new Point(0, 0));
this.pictureBox1.Image = img;
}
private void refresh_Click(object sender, EventArgs e)
{
createcaptcha();
}
private void verify_Click(object sender, EventArgs e)
{
if (textBox1.Text == number.ToString())
{
MessageBox.Show("match");
}
else
{
MessageBox.Show("not match");
}
}
Here,
Learn, how to design numbered based captcha. Actually, we will write some randomly generated number on image. After that we compare that number with the text box.
Video Contain Full code implementation details:
Copy this code and paste in the code file:
int number = 0;private void createcaptcha()
{
Random r1 = new Random();
number = r1.Next(10, 1000);
Image img = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
var font = new Font("TimesNewRoman", 25, FontStyle.Bold, GraphicsUnit.Pixel);
var graphics = Graphics.FromImage(img);
graphics.DrawString(number.ToString(), font, Brushes.Red, new Point(0, 0));
this.pictureBox1.Image = img;
}
private void refresh_Click(object sender, EventArgs e)
{
createcaptcha();
}
private void verify_Click(object sender, EventArgs e)
{
if (textBox1.Text == number.ToString())
{
MessageBox.Show("match");
}
else
{
MessageBox.Show("not match");
}
}
Here,
- Bitmap class is used for picking width and height parameter from the picture box.
- Using Font class, set the font style, font family and graphics unit that is pixel.
- Using Graphics class draw string on the picture, i have used randomly generated number.
- Now, assign the image to the picture box.
Comments
Post a Comment