在asp.net中动态创建控件 [英] Dynamically create controls in asp.net
本文介绍了在asp.net中动态创建控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的asp.net项目中动态创建链接按钮.
请在这方面帮助我..
hi i want to create link buttons dynamically in my asp.net project.
pls help me in this regards..
how to create them n where to define events for them?
推荐答案
您可以在Google上找到相关示例.如果您要添加按钮,则代码如下所示:
You can find examples on google for this. This is how your code would look like if you are adding a button:
Button button = new Button();
// Set properties here
button.Click += new EventHandler(ClickEventHandlerName);
// You can also use any other container instead of directly adding to page
Page.Controls.Add(button);
动态控件应添加到PreRender中.
Dynamic controls should be added in PreRender.
这篇关于在asp.net中动态创建控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文