0

我在我的 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() 中创建按钮,稍后我在创建后添加控制面板。

任何帮助或视线将不胜感激

4

2 回答 2

0

ModalPopupExtender 有一个属性 CancelcontrolID 或类似的东西......如果您要指定 TargetControlID,那么也指定 CancelControlID

于 2012-12-14T08:48:24.637 回答
0
        <ajaxToolkit:UpdatePanel ID="UpdatePanel3" runat="server">
        <ContentTemplate>
            <asp:Button ID="fake2" runat="server" Style="display: none" />
            <Ajax:ModalPopupExtender ID="mpe_Mail" runat="server" BackgroundCssClass="modalBackground"
                TargetControlID="fake2" PopupControlID="pnl_Mail" CancelControlID="btn_Close">
            </Ajax:ModalPopupExtender>
            <asp:Panel ID="pnl_Mail" runat="server" Style="display: none;" CssClass="modalBackground1">
                <table width="350" border="0" align="center" cellpadding="0" cellspacing="0" style="background: #fff;">
                    <tr>
                        <div class="Lecture-Planform-headx">
                            <asp:Label ID="lbl_Employer" runat="server" />
                        </div>
                    </tr>
                    <tr>
                        <td align="center">
                            <div>
                                --This is table--
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div align="center">
                                <asp:Button ID="btn_Close" runat="server" CausesValidation="false" Text="Back" CssClass="activebutton2" OnClick="<--Add Your Function Hear-->" />
                            </div>
                        </td>
                    </tr>
                </table>
            </asp:Panel>
        </ContentTemplate>
    </ajaxToolkit:UpdatePanel>
于 2012-12-14T09:00:47.787 回答