我正在开发一个幸运系统的项目,但我不知道如何使标签显示像数字计数器动画。标签是来自文本文件的员工ID。下面是我的代码。
public partial class _Default : System.Web.UI.Page
{
private Random random = new Random();
private string testFilePath = @"C:\Users\Nor Asyraf Mohd No\Documents\TestFile.txt";
private List<string> testFileLines;
protected void Page_Load(object sender, EventArgs e)
{
if (!File.Exists(testFilePath))
{
Response.Write($"The file does not exist: {testFilePath}");
}
else
{
try
{
testFileLines = File.ReadAllLines(testFilePath).ToList();
}
catch (Exception ex)
{
Response.Write($"Could not read file {testFilePath}. Exception details: {ex}");
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (testFileLines != null && testFileLines.Count > 0)
{
var randomLine = testFileLines[random.Next(testFileLines.Count)];
Label1.Text = randomLine;
testFileLines.Remove(randomLine);
}
}
}