我将一个dbcontext对象分配给标签onclick。问题是dbcontext对象未显示在Web浏览器中。相反,没有什么。它应该显示计数器的int值。如何分配并在标签中显示?
protected void startOverButton_Click(object sender, EventArgs e)
{
gameOverLabel.Visible = false;
answerStatus.Visible = true;
Session["AttemptCount"] = 0;
Session["strikes"] = 0;
int answer = randomNumber1 + randomNumber2;
counter = (int)Session["AttemptCount"];
int strikeCounter = (int)Session["strikes"];
if (mathAnswerTextBox.Text == answer.ToString())
{
counter += 5;
Session["AttemptCount"] = counter;
answerStatus.Text = "Correct!";
warningLabel.Visible = true; ;
scoreLabel.Text = "Score: " + counter.ToString();
randomNumber1 = random.Next(0, 50);
randomNumber2 = random.Next(0, 50);
num1Label.Text = Convert.ToString(randomNumber1);//add this line
num2Label.Text = Convert.ToString(randomNumber2); //and this line
num1Label.Visible = true;
num2Label.Visible = true;
mathAnswerTextBox.Visible = true;
submitAnswerButton.Visible = true;
}