How to do client callback for each item in a foreach statement using c#?
- by Mike108
I want to show each item Id that is doing now dynamically in a foreach statement.
How to do some kind of client callback to show the item Id in a foreach statement?
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
.
protected void Button1_Click(object sender, EventArgs e)
{
List<int> list = new List<int>()
{
1,2,3,4,5
};
foreach (var item in list)
{
Label1.Text = string.Format("I'm doing item {0} now.", item.ToString());
Page.RegisterStartupScript("", string.Format("<script>alert('doing item {0} now')</script>", item.ToString()));
Thread.Sleep(1 * 1000);
}
}