我在我的 asp.net 页面中没有触发按钮时遇到问题,我想知道是否有人可以让我看到这个问题。
首先你需要知道的是我使用 modalpopupexntender 来弹出面板,在最后一个面板上我开始动态地将控件添加到现有面板。
这是存在的面板,并且控件是动态添加的
<asp:ModalPopupExtender ID="ModalPopupExtender10" runat="server" TargetControlID="hndPage5" OkControlID="imgExitEdit1"
PopupControlID="pnlReview" BackgroundCssClass="LoadingBackground" >
</asp:ModalPopupExtender>
<input type="hidden" runat="server" id="hndPage5" />
<asp:Panel runat="server" ID="pnlReview" CssClass="Modal450h450w" Height="300px">
This is table
</asp:Panel>
我开始从这段代码向上面的面板添加控件,这个事件也来自另一个带有按钮的 modalpopupextender:
protected void btnReview_Button_Click(object sender, EventArgs e)
{
HtmlTable table = new HtmlTable();
DataTable tblBillingAddress = Members.MemberBillingAddressSearch(MemberID);
for (int i = 0; i < tblBillingAddress.Columns.Count; i++)
{
CreateRow(tblBillingAddress.Columns[i].ColumnName.ToString(), tblBillingAddress.Rows[0][tblBillingAddress.Columns[i].ColumnName].ToString(), table);
}
Button btn = (Button)sender;
if (btn.ID == "btnIbanReview")
{
CreateRow("thing", thing.Text, table);
CreateRow("other", other.Text, table);
}
else if (btn.ID == "btnrrTReview")
{
CreateRow("this", this.Text, table);
}
Button btnBack = new Button();
Button btnConfirm = new Button();
btnBack.ID = "btnReviewClose";
btnConfirm.ID = "btnReviewConfirm";
btnBack.Text = "Back";
btnConfirm.Text = "Confirm";
btnBack.Click += new EventHandler(this.btnAdd_Close_Click);
btnConfirm.Click += new EventHandler(this.btnConfirm_Click);
HtmlTableCell cell1 = new HtmlTableCell();
HtmlTableCell cell2 = new HtmlTableCell();
cell1.Controls.Add(btnBack);
cell2.Controls.Add(btnConfirm);
HtmlTableRow rr = new HtmlTableRow();
rr.Cells.Add(cell1);
rr.Cells.Add(cell2);
table.Rows.Add(rr);
pnlReview.Controls.Add(table);
pnlReview.Visible = true;
ModalPopupExtender10.Show();
}
这是 CreateRow() 方法:
private void CreateRow(string heading, string value, HtmlTable hTable)
{
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell cHeading = new HtmlTableCell();
HtmlTableCell cValue = new HtmlTableCell();
cHeading.InnerText = heading;
cHeading.Style.Add("font-weight", "bold");
row.Cells.Add(cHeading);
cValue.InnerText = value;
row.Cells.Add(cValue);
hTable.Rows.Add(row);
}
这是我创建的事件:
void btnConfirm_Click(object sender, EventArgs e)
{
ModalPopupExtender10.Hide();
}
我尝试在 Page_Init()、Page_Onit() 和 Page_Load() 中创建按钮,稍后我在创建后添加控制面板。
任何帮助或视线将不胜感激