2

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);
Black Frog
  • 11,595
  • 1
  • 35
  • 66
user3236142
  • 29
  • 1
  • 1
  • 4
  • 1
    if you just want to show a string message a `MessageBox` should be enough, add a handler for the button's `Click` event and show the `MessageBox` – grabthefish Jan 06 '15 at 15:09
  • What is in the popup window? – ZoomVirus Jan 06 '15 at 15:11
  • 1
    The previous comment say use `MessageBox` and your question say __popupwindow__. When I think is __popupwindow__ I am thinking you are doing ASP.Net and you want a **javascript** solution. MessageBox sounds more like WinForm and dialog box. – Black Frog Jan 06 '15 at 15:12
  • Is this for a website? It looks like WebForms code. – jtimperley Jan 06 '15 at 15:13
  • [`TableRow`](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.tablerow.aspx) looks like [tag:asp.net] to me. – Sinatr Jan 06 '15 at 15:21
  • its asp.net, and its for a part of a website. the config button should show a popup box with field names. however I cant seem to get that to work – user3236142 Jan 06 '15 at 15:57
  • @Gunther34567 this is a webforms question, MessageBox solution is for winforms and will not work here. – Taylor Brown Jan 06 '15 at 17:00
  • @taybriz yeah i posted the comment before the asp tag was added – grabthefish Jan 06 '15 at 19:58

2 Answers2

0

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;
Black Frog
  • 11,595
  • 1
  • 35
  • 66
0

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

Taylor Brown
  • 1,689
  • 2
  • 17
  • 33