这是我为按钮准备的代码。我希望配置按钮在单击时显示一个弹出窗口。我查阅并尝试了很多不同的代码,但没有一个有效。我觉得我缺少一个关键组件,但我不确定那是什么。感谢帮助!
tr = new TableRow();
// Create the cell
tc = new TableCell();
tc.Width = Unit.Point(300);
tc.BorderWidth = 0;
tc.BorderStyle = BorderStyle.None;
Button ConfigButton = new Button();
ConfigButton.Text = "Configuration";
ConfigButton.Visible = true;
tc.Controls.Add(ConfigButton);
tr.Cells.Add(tc);
tbl.Controls.Add(tr);
最佳答案
Using JavaScript Along with ASP.NET您将执行以下操作:
// when you create the button, you can add attributes
Button ConfigButton = new Button();
// this example will display alert dialog box
ConfigButton.Attributes.Add("onclick", "javascript:alert('ALERT ALERT!!!')");
// to get you popup windows
// you would use window.open with the BLANK target
ConfigButton.Text = "Configuration";
ConfigButton.Visible = true;
关于c# - 单击按钮时如何创建弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27801402/