本文发表在 rolia.net 枫下论坛//add a control that will blot out the others
HtmlGenericControl divOverlay = new HtmlGenericControl("div");
divOverlay.Style["background-color"] = "#EBEBEB";
divOverlay.Style["width"] = "100%";
divOverlay.Style["height"] = "100%";
divOverlay.Style["position"] = "absolute";
divOverlay.Style["top"] = "0px";
divOverlay.Style["left"] = "0px";
divOverlay.Style["filter"] = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
//add a "modal" div that shows overtop of everything
HtmlGenericControl div = new HtmlGenericControl("div");
div.Style["width"] = "100%";
div.Style["height"] = "70%";
div.Style["position"] = "absolute";
div.Style["top"] = "30%";
div.Attributes["align"] = "center";
HtmlGenericControl div2 = new HtmlGenericControl("div");
div2.Attributes["style"] = "background-color: white; border: 1px solid gray; padding: 8px; text-align:left; width: 300px";
//show a table with an editable version of the "Edited" column
HtmlTable table = new HtmlTable();
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell cell1 = new HtmlTableCell();
HtmlTableCell cell2 = new HtmlTableCell();
cell2.Align = "right";
table.Border = 0;
table.Width = "100%";
table.Rows.Add(row);
row.Cells.Add(cell1);
row.Cells.Add(cell2);
Literal lit = new Literal();
lit.Text = "Edit selected " + inputElem.GetAttribute("gridlabel").Replace(" ", " ") + ": ";
Control c = Page.ParseControl(inputElem.OuterXml);
if (c.Controls.Count == 1) c = c.Controls[0];
cell1.Controls.Add(lit);
if (c is HtmlInputControl && ((HtmlInputControl)c).Attributes["readonly"] == "true") ((HtmlInputControl)c).Attributes.Remove("readonly");
if (c is HtmlSelect && ((HtmlSelect)c).Style["display"] == "none") ((HtmlSelect)c).Style.Remove("display");
cell1.Controls.Add(c);
//add the validators
AddValidatorsAndDataSources(cell1, c, c.ID, inputElem, false);
HtmlButton buttonOK = new HtmlButton();
buttonOK.InnerText = "Update";
buttonOK.Attributes["onclick"] = Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this, "UpdateColumn", "", true, false, false, true, true, ""));
HtmlButton buttonCancel = new HtmlButton();
buttonCancel.InnerText = "Cancel";
buttonCancel.Attributes["onclick"] = Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this, "CancelColumnEdit", "", true, false, false, true, false, ""));
Literal litSpace = new Literal();
litSpace.Text = " ";
cell2.Controls.Add(buttonOK);
cell2.Controls.Add(litSpace);
cell2.Controls.Add(buttonCancel);
div.Controls.Add(div2);
div2.Controls.Add(table);
Controls.Add(divOverlay);
Controls.Add(div);更多精彩文章及讨论,请光临枫下论坛 rolia.net