简体   繁体   中英

How to create a pop up window when a button is clicked

This is the code I have for the button. I want the configbutton to display a pop up window when clicked on. I have looked up and tried a lot of different codes but none of them work. I feel like I am missing a key component but I am not sure what that is. Appreciate the help!

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 you will do the following:

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

I recommend looking into using the AJAX Control Toolkit ModalPopupExtender. This is what I use for my pop ups in ASP.NET.

Here is a link to he AJAX Control Toolkit samples website showing how this control works: http://www.ajaxcontroltoolkit.com/ModalPopup/ModalPopup.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM