在ASP.Net中添加动态控件 [英] Adding dynamic Controls in ASP.Net

查看:84
本文介绍了在ASP.Net中添加动态控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何在ASP.NET中动态添加控件.

我使用了HtmlGenericControls并将它们添加到div标签中.现在我的问题是,我想在创建控件后立即在页面上显示该控件,即是否添加了< p>标签或< a>标记,然后将其添加到< div>标签.我想在创建div标签后立即对其进行显示.

我使用递归函数创建了多达100个这样的div标签.现在,在创建所有100个标签之后,页面就会更新,但是我想在它们创建后立即添加它们.

我已经使用过AJAX更新面板,但是它对我不起作用.
有人可以在这方面给我建议吗.

I know how to add controls dynamically in ASP.NET.

I used HtmlGenericControls and added them to a div tag. Now my problem is that, I want to display the control on the page as soon as they are created, i.e. if I add a <p> tag or <a> tag and then add it to a <div> tag. I want to show the div tag as soon as its created.

I have created as many as nearly 100 such div tag using a recursive function. Now the page is updated after all the 100 tags are created but I want to add them as soon as they are created.

I have used the AJAX Update panel, but its not working for me.
Can anyone suggest me a good thing in this.

推荐答案

检查此内容

Adding-controls-dynamicly-to-an-updatepanel- in-asp-net-ajax [ ^ ]
Check this

Adding-controls-dynamically-to-an-updatepanel-in-asp-net-ajax[^]


现在,在创建所有100个标记之后,页面会更新,但我想将它们添加为它们一被创建
这是在您遵循页面生命周期的更新面板路线进行的,并且一旦完成传送,就将重新呈现更新面板部件.

而是使用纯Javascript.在客户端,循环遍历并创建div并将其添加到容器中.一旦添加它们,它们就会显示出来.
Now the page is updated after all the 100 tags are created but I want to add them as soon as they are created
This is happening as you you are taking an update panel route that follows the page life cycle and once eveything is done then the update panel part gets re-rendered.

Instead, use plain Javascript. On client side, loop through and create the divs and add them to the containers. As soon they will be added they will get displayed.


这篇关于在ASP.Net中添加动态控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆