I would like to add elements (paragraphs to be specific) to webpage after clicking a button with some time delay. Basicly in pseudocode I want to do something like this:
OnButtonClick()
{
for (int i=0; i<10; i++)
{
AddParagraph("Paragraph "+i); // and make it visible
Delay(1000);
}
}
However I want to make it visible for the user. Everything I've made so far is blocking the UI for 10 seconds and then showing it all at once. I don't mind blocking user interaction, but I want to show one new paragraph every second.
Is it possible to achive that? I'm pretty new to .NET so please try keep it simple. I need no more then "working" solution.
This is possible, definitely, but you would have to make use of client side Javascript and forget about server side delays.
An idea is to render all paragraphs from server with
display : none
style and have a javascript timer that fires every second and changes the style of next paragraph tounset
.You can store the paragraph nubmer in a local variable and increment it until you reach the last one so that ech time the timer fires you set up another one if there are paragraphs left to show.