0

currently i have 3 user control in my .aspx file

  <tr>
            <td>
                <ucM ID="M4" runat="server" />
            </td>
            <td>
                <ucM ID="M5" runat="server" />
            </td>
            <td>
                <ucM ID="M6" runat="server" />
            </td>
        </tr>

what i am trying to do is :

  1. added a button

<asp:Button  ID="Button1" runat="server" Text="ok" OnClick ="Button1_Click"/>

2.for one click adding one more user control to main page with different id .

i was tried like below :-

1.first try aspx.cs:-

   protected void Button1_Click(object sender, EventArgs e)
     {
         Medt con = (Med)LoadControl("~/Med.ascx");
         form1.Controls.Add(con);
     }

aspx:-

<formr id="form1" runat="server">

2.secound try aspx.cs:-

protected void Button1_Click(object sender, EventArgs e)
   {
           InnerHtmlKeeper += "<table id = '" + x + "'> <tr> <td><ucM:M ID='rtyry' 
           runat='server' /></td> </tr> </table>";
           divPlaceOnme.InnerHtml = InnerHtmlKeeper;
   }

aspx file :-

<formr id="form1" runat="server">
<div runat="server" id="divPlaceOnme"></div>
<asp:Button  ID="Button1" runat="server" Text="ok" OnClick ="Button1_Click"/>

is there any possible way to do my requirement ?

ADyson
  • 57,178
  • 14
  • 51
  • 63
ABCD
  • 379
  • 1
  • 8
  • 25
  • 1
    Have you tried a repeater? – Salik Rafiq Jun 11 '21 at 13:54
  • no bro . i am confused with that . – ABCD Jun 11 '21 at 13:54
  • The Repeater control is used to display a repeated list of items that are bound to the control. my case i need to add blank controls with different id. forgive me if i am wrong – ABCD Jun 11 '21 at 13:56
  • 1
    You try something like this. https://stackoverflow.com/questions/1883074/asp-net-repeating-input-boxes-on-the-client-side-using-repeater Note that you need to recreate the inputs each time as they are dynamic. You can use a repeater on anything - a list , so you could create a viewstate vector in there with the values and keep binding the repeater to it. – Salik Rafiq Jun 11 '21 at 14:03

0 Answers0