Hello,
I'm trying to add controls to page without postback with ajax.
The following code works but it adds the controls at once not one by one. I want that it dynamically adds and show the controls.
I've seen several php sites that dynamically refresh the page content one by one without postback.
C# code:
protected void Button1_Click(object sender, EventArgs e)
{
System.Net.WebClient c = new System.Net.WebClient();
for (int i = 0; i < 10; i++)
{
string result = c.DownloadString("http://www.gmail.com");
Label lbl = new Label();
lbl.ID = "lbl" + i.ToString();
lbl.Text = "lbl" + i.ToString();
UpdatePanel1.ContentTemplateContainer.Controls.Add(lbl);
UpdatePanel1.Update();
System.Threading.Thread.Sleep(500);
}
}
HTML code:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
We need this because In our free seo tools website we have several tools that we need to show the results to users dynamically.
You may see a page that we want to work this way, http://www.onlineseoanalyzer.com/Free-SEO-Tools/Free-Backlink-Generator.aspx
This tool generate backlinks on appr. 100 websites for a given website, but it shows the result after all backlink generation completed. We want to show the result for every backlink generation is done.