开发者

adding textboxes to panel in modal popup

开发者 https://www.devze.com 2023-04-12 18:26 出处:网络
How can I dynamically add text boxes to a Panel in a modal popup? I am trying this so far with no luck....

How can I dynamically add text boxes to a Panel in a modal popup? I am trying this so far with no luck....

There is a gridview that pops up a modal panel where I would like to dynamically add textboxes.

UPDATED CODE IN FOR LOOP:

int num = 4;
int I;
// Create TB's
for (I = 1; I <= num; I++)
{
        Panel newPanel = (Panel)Page.Master.FindControl("pnlpopup");
        PlaceHolder MainContent2 = (PlaceHolder)newPanel.FindControl("PlaceHolder3");

        TextBox txtB = new TextBox();
        txtB.ID = "txtBEdit" + I.ToString("D2");
        MainContent2.Controls.Add(txtB);
}

this.ModalPopupExtender.Show();here

This is the aspx.

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<title>Untitled Page</title>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>

<asp:ModalPopupExtender ID="ModalPopupExtender" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlpopup" CancelControlID="btnCancel" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>

<asp:Label ID="lblresult" runat="server"/>
<asp:Button ID="btnShowPopup" runat="server" style="display:none" />
<asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="650px" 
    Width="500px" Font-Size="Small">
<table width="100%" style="border:Solid 3px #D55500; width:100%; height:100%" cellpadding="1" cellspacing="1">
    <tr style="background-color:#D55500">
    <td colspan="2" style=" height:10%; color:White; font-weight:bold; font-size:larger" align="center">Foreign Text Input</td>
    </tr>
    <tr>
        <td align="left" style=" width:20%">ID:
        </td>
        <td>
            <asp:Label ID="lblID" runat="server"></asp:Label>
        </td>
    </tr>
    <tr>
        <td align="left">English text:
        </td>
        <td>
       开发者_运维百科    <asp:Label ID="data_text" runat="server"></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
        <asp:PlaceHolder ID="PlaceHolder3" runat="server"></asp:PlaceHolder>


        <!--Textboxes will be added here -->


        </td>
    </tr>
    <tr>
        <td>
        </td>
        <td>
            <asp:Button ID="btnUpdate" CommandName="Update" runat="server" Text="Update" onclick="btnUpdate_Click"/>
            <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
        </td>
    </tr>
</table>
</asp:Panel>
</div>
</asp:Content>

To provide the solution I am adding the below line of code....

PlaceHolder MainContent2 = (PlaceHolder)PlaceHolder3.FindControl("PlaceHolder3");


Since PlaceHolder3 is an

<asp:PlaceHolder ID="PlaceHolder3" runat="server"></asp:PlaceHolder>

you should be able to access it via this.PlaceHoder3 directly. If not, then add

protected PlaceHolder PlaceHolder3;

to your class definition.

0

精彩评论

暂无评论...
验证码 换一张
取 消