Add control in UpdatePanel
-
Hi. I have an UpdatePanel in a UserControl that there is a button on it. By clicking the button I want to add a control (textBox) dynamically to my WebForm. but it doesn't work. If I remove the UpdatePanel that works, but with UpdatePanel Not. What can I do?
Best wishes
-
Hi. I have an UpdatePanel in a UserControl that there is a button on it. By clicking the button I want to add a control (textBox) dynamically to my WebForm. but it doesn't work. If I remove the UpdatePanel that works, but with UpdatePanel Not. What can I do?
Best wishes
-
Hi. I have an UpdatePanel in a UserControl that there is a button on it. By clicking the button I want to add a control (textBox) dynamically to my WebForm. but it doesn't work. If I remove the UpdatePanel that works, but with UpdatePanel Not. What can I do?
Best wishes
So, am I right in saying that your button is doing a postback and your page is reloading(no ajax)? If this is the case then I think it's the Triggers section of the UpdatePanel that you're missing. See my sample code below (you can ignore the content, it's just a report I knocked up). I've made bold and italic the Triggers section I think you could be missing. Also, the code where your dynamic control will be added will have to go in the ContentTemplate section of your UpdatePanel. My apologies if I've missed the point and you're already doing this.
<asp:Button ID="btnRun\_TopHopFaults" runat="server" Text="Run Report" OnClick="btnRun\_TopHopFaults\_Click" /> <asp:UpdatePanel id="pnlTopHopFaultsResults" runat="server" UpdateMode="Conditional"> _**<Triggers> <asp:AsyncPostBackTrigger ControlID="btnRun\_TopHopFaults" /> </Triggers>**_ <ContentTemplate> <asp:Repeater ID="repTopHopFaults" runat="server"> <HeaderTemplate> <table> <tr> <th></th> <th>Guidance Ref</th> <th>Guidance</th> <th>Quantity</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td><%#DataBinder.Eval(Container.DataItem, "Position") %></td> <td><a href='<%#string.Concat("javascript:showHopDrillDown(", DataBinder.Eval(Container.DataItem, "ID"), ")")%>'> <%#DataBinder.Eval(Container.DataItem, "FieldRef") %> </a> </td> <td><%#DataBinder.Eval(Container.DataItem, "Field") %></td> <td><%#DataBinder.Eval(Container.DataItem, "FaultCount") %></td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater>