在我的表单中,我添加了一个内容占位符,还在内容占位符中手动添加了一个按钮。但现在我想在运行时在同一内容占位符中添加一个按钮。我尝试了以下代码,但该按钮未在浏览器中显示... 我不知道这里有什么问题......
我的代码...
ContentPlaceHolder content = (ContentPlaceHolder)this.Master.FindControl("maincontent");
Button newButton = new System.Web.UI.WebControls.Button();
newButton.ID = "NextButton";
newButton.Text = "Next";
newButton.Visible = true;
content.Controls.Add(newButton);
最佳答案
您丢失了按钮的大小和位置。
关于c# - 如何在运行时在 asp.net 中的内容占位符中添加按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12527109/