Server Control in UpdatePanel not adding children

Last post 02-23-2008 6:38 AM by neetu07081. 3 replies.

Sort Posts:

  • Server Control in UpdatePanel not adding children

    11-30-2006, 6:23 PM
    • Member
      136 point Member
    • Puhfista
    • Member since 03-08-2006, 4:29 AM
    • Logan, Utah
    • Posts 47

    Hey all. I did a search to see if this has already been addressed but I came back empty.

     I have a asp:panel inside of a asp:updatepanel. What I want to do is add controls to it using an async postback. The first time I press the button to add the controls, it works, but after that, nothing.

     Here is my code.

    <asp:UpdatePanel RenderMode="Inline" runat='server' ID="pnlAJAX">
    <ContentTemplate>
        <asp:Panel runat="server" ID="pnlAKAs" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnAddAka" />
    </Triggers>
    </asp:UpdatePanel>
    <br />
    <asp:Button runat="server" ID="btnAddAka" Text="+" OnClick="btnAddAka_OnClick" />

        protected void btnAddAka_OnClick(object sender, EventArgs e)
        {
            AddRow();
        }

        void AddRow()
        {
            TextBox txtLastName = new TextBox();
            TextBox txtFirstName = new TextBox();
            TextBox txtMiddleName = new TextBox();


            pnlAKAs.Controls.Add(new LiteralControl("Last Name: "));
            pnlAKAs.Controls.Add(txtLastName);
            pnlAKAs.Controls.Add(new LiteralControl("First Name: "));
            pnlAKAs.Controls.Add(txtFirstName);
            pnlAKAs.Controls.Add(new LiteralControl("Middle Name: "));
            pnlAKAs.Controls.Add(txtMiddleName);
            pnlAKAs.Controls.Add(new LiteralControl("<br />"));
           
        }

     

    Any suggestions would be greatly appreciated 

    Filed under: ,
  • Re: Server Control in UpdatePanel not adding children

    11-30-2006, 8:02 PM
    • Member
      136 point Member
    • Puhfista
    • Member since 03-08-2006, 4:29 AM
    • Logan, Utah
    • Posts 47

    I got it to work.

     Apparently the Panel "forgets" it's old state when the page is done loading, so I had to use Session variables to perpetuate the controls it had, then add to it.

    I know there is a better way, though.
     

  • Re: Server Control in UpdatePanel not adding children

    02-23-2008, 6:35 AM
    • Member
      4 point Member
    • neetu07081
    • Member since 02-23-2008, 6:34 AM
    • Posts 2

     

    how d u slved this plz tell me

     

     

     

    Hey all. I did a search to see if this has already been addressed but I came back empty.

     I have a asp:panel inside of a asp:updatepanel. What I want to do is add controls to it using an async postback. The first time I press the button to add the controls, it works, but after that, nothing.

     Here is my code.

    <asp:UpdatePanel RenderMode="Inline" runat='server' ID="pnlAJAX">
    <ContentTemplate>
        <asp:Panel runat="server" ID="pnlAKAs" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnAddAka" />
    </Triggers>
    </asp:UpdatePanel>
    <br />
    <asp:Button runat="server" ID="btnAddAka" Text="+" OnClick="btnAddAka_OnClick" />

        protected void btnAddAka_OnClick(object sender, EventArgs e)
        {
            AddRow();
        }

        void AddRow()
        {
            TextBox txtLastName = new TextBox();
            TextBox txtFirstName = new TextBox();
            TextBox txtMiddleName = new TextBox();


            pnlAKAs.Controls.Add(new LiteralControl("Last Name: "));
            pnlAKAs.Controls.Add(txtLastName);
            pnlAKAs.Controls.Add(new LiteralControl("First Name: "));
            pnlAKAs.Controls.Add(txtFirstName);
            pnlAKAs.Controls.Add(new LiteralControl("Middle Name: "));
            pnlAKAs.Controls.Add(txtMiddleName);
            pnlAKAs.Controls.Add(new LiteralControl("<br />"));
           
        }

     

    Any suggestions would be greatly appreciated

     

     

  • Re: Server Control in UpdatePanel not adding children

    02-23-2008, 6:38 AM
    • Member
      4 point Member
    • neetu07081
    • Member since 02-23-2008, 6:34 AM
    • Posts 2

    I want to keep scrollbar of gridview at the bottom of the scroll bar and my gridview is filled by using timer using ajax update panel and also using  <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick"  />  so please tell me how to maintain scrollbar positio of gridview at bottom when gridview is filled by using timer

     

Page 1 of 1 (4 items)