[英]ASP.NET Controls are not dynamically added to the panel on page refresh
In asp.net project, I am trying to add controls to the panel in C# on a button click event在 asp.net 项目中,我试图在按钮单击事件上将控件添加到 C# 中的面板
When I put a debugger breakpoint then I can see the item being added but when the page is shown on the browser, the panel is emptyu.当我放置一个调试器断点时,我可以看到正在添加的项目,但是当页面显示在浏览器上时,面板是空的。
I've tried adding.Page.PostBack but still no luck.我试过添加.Page.PostBack 但仍然没有运气。
Am I missing something?我错过了什么吗?
protected void Test(object sender, DirectEventArgs e) {受保护的无效测试(对象发送者,DirectEventArgs e){
Panel configurationPanel = new Panel(); configurationPanel.Title = "My Added Panel"; configurationPanel.Height = 100; pnlInfo.Items.Add(configurationPanel); }
Hits the break point and pnlInfo.Items.Count = 1 but it does not show on the page.达到断点和 pnlInfo.Items.Count = 1 但它没有显示在页面上。
did u try你试过了吗
pnlInfo.Controls.Add(configurationPanel);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.