using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Webpages_Event_Registration : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RandomNum();
}
}
private void RandomNum()
{
Random rnd = new Random();
string num = rnd.Next(0, 9).ToString();
lblRandomNo1.Text = num;
Random rnd2 = new Random();
string num2 = rnd.Next(0, 9).ToString();
lblRandomNo2.Text = num2;
lblAddRandom.Text = lblRandomNo1.Text + " + " + lblRandomNo2.Text + " = ";
int RandomNo1 = int.Parse(lblRandomNo1.Text.ToString());
int RandomNo2 = int.Parse(lblRandomNo2.Text.ToString());
int RandomNoSum = RandomNo1 + RandomNo2;
lblSum.Text = RandomNoSum.ToString();
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (lblSum.Text == txtSumRandom.Text)
{
lblSum12.Text = "Sum :" + txtSumRandom.Text;
Response.Write("");
FnClear();
}
else
{
Response.Write("");
lblSum12.Text = "-";
}
}
private void FnClear()
{
lblRandomNo1.Text = "";
lblRandomNo2.Text = "";
lblAddRandom.Text = "__ + __ = ";
lblSum.Text = "";
lblSum12.Text = "";
txtSumRandom.Text = "";
}
protected void btnReset_Click(object sender, EventArgs e)
{
FnClear();
}
}