Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在单击按钮时创建弹出窗口_C#_Asp.net_Button_Popupwindow - Fatal编程技术网

C# 如何在单击按钮时创建弹出窗口

C# 如何在单击按钮时创建弹出窗口,c#,asp.net,button,popupwindow,C#,Asp.net,Button,Popupwindow,这是我的按钮代码。我希望configbutton在单击时显示一个弹出窗口。我已经查找并尝试了许多不同的代码,但都不起作用。我觉得我缺少了一个关键的组成部分,但我不确定那是什么。谢谢你的帮助 tr = new TableRow(); // Create the cell tc = new TableCell(); tc.Width = Unit.Point(300); tc.BorderWidth = 0; tc.BorderStyle = BorderStyle.None; Button Co

这是我的按钮代码。我希望configbutton在单击时显示一个弹出窗口。我已经查找并尝试了许多不同的代码,但都不起作用。我觉得我缺少了一个关键的组成部分,但我不确定那是什么。谢谢你的帮助

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);
您将执行以下操作:

// 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;

我建议您考虑使用AJAX控制工具包ModalPopupXtender。这是我在ASP.NET中用于弹出窗口的内容

以下是指向AJAX控件工具包示例网站的链接,该网站展示了该控件的工作原理:

如果您只想显示字符串消息,
MessageBox
应该足够了,为按钮的
单击事件添加一个处理程序,并显示弹出窗口中的
MessageBox
内容?前面的注释说使用
MessageBox
,您的问题说弹出窗口。当我认为是popupwindow时,我认为你在做ASP.Net,你想要一个javascript解决方案。MessageBox听起来更像WinForm和dialog box。这是用于网站的吗?它看起来像WebForms代码。在我看来很像。