c# - 单击按钮时如何创建弹出窗口

标签 c# asp.net button popupwindow

这是我为按钮准备的代码。我希望配置按钮在单击时显示一个弹出窗口。我查阅并尝试了很多不同的代码,但没有一个有效。我觉得我缺少一个关键组件,但我不确定那是什么。感谢帮助!

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/

相关文章:

c# - 如何阻止按钮控件中的文本在 Winforms 中将单词分成多行?

c# - Xamarin 中的 SignaturePadView 在 ios 和 android 上形成不同

asp.net - 用于验证的数据注释,至少一个必填字段?

php - 检查是否已收到邮寄请求

asp.net - ASPxComboBox - 如何设置所选项目?

c# - 如何在Web.Config中完全摆脱customErrors?

java - 如果文本字段已填充,则设置启用按钮

c# - 如何使用 EPPlus 将 excel 行解析回类型

c# - 使用 Prism MVVM 的 OpenFileDialog

c# - 如何从 Selenium 访问 Chrome 开发者控制台