Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8502649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:32:39+00:00 2026-06-11T01:32:39+00:00

This is the Design::: <asp:Panel ID=Panel1 runat=server> </asp:Panel> <asp:Button ID=Button2 runat=server Text=Button /> <asp:Label

  • 0
This is the Design:::

<asp:Panel ID="Panel1" runat="server">
</asp:Panel>
<asp:Button ID="Button2" runat="server" Text="Button" />
<asp:Label ID="l1" runat="server" Text="0"></asp:Label>
<asp:Label ID="l2" runat="server" Text="0"></asp:Label>



Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim i As Integer = 0
    Dim j As Integer = 0
    l1.Text = l2.Text
    l2.Text = Val(l2.Text) + 10
    i = Val(l1.Text)
    j = Val(l2.Text)
    MsgBox(i & " " & j)
    While (i < j)
        Dim b As Button = New Button()
        b.ID = "b" + i.ToString()
        b.Text = b.ID
        Panel1.Controls.Add(b)
        i = i + 1
    End While
End Sub

This contains a button on click it should create 10 unique buttons..
i want to append all created buttons with existing buttons..
but the program is overriding instead of adding controls to the panel
help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:32:41+00:00Added an answer on June 11, 2026 at 1:32 am

    I think you want to add 10 dynamic controls on every button click. The problem you are facing right know is that on first click it adds 10 button controls, and on subsequent clicks it overrides the previous controls. Dynamic controls are created every time the page is requested so you have to create them on every request.

    I write the following code to solve your query and it works:

    // Aspx code
    <asp:Panel ID="Panel1" runat="server">
     </asp:Panel>
    <asp:Button ID="Button2" runat="server" Text="Button" />
    <asp:Label ID="l1" runat="server" Text="0"></asp:Label>
    <asp:Label ID="l2" runat="server" Text="0"></asp:Label>
    
    // Code BEhind
    
     Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim i As Integer = 0
        Dim j As Integer = 0
        l1.Text = l2.Text
        l2.Text = Val(l2.Text) + 10
        i = Val(l1.Text)
        j = Val(l2.Text)
        MsgBox(i & " " & j)
    
        Dim lst As List(Of Integer) = New List(Of Integer)  'Create a list of integer type
        lst.Add(i)  'Save value of i
        lst.Add(j)
    
        If Not Session("id_0") Is Nothing Then ' Will Check session for First Click exist or not
    
            For k As Integer = 0 To DirectCast(Session("click"), Integer)
    
                Dim mylst As List(Of Integer) = New List(Of Integer)
                mylst = DirectCast(Session("id_" & k), List(Of Integer)) ' Assign Session Value to List
                If Not mylst Is Nothing Then
                    WriteControls(mylst(0), mylst(1)) ' Call the function
                End If
    
    
            Next
    
    
        End If
    
        Session("id_" & DirectCast(Session("click"), Integer)) = lst  ' Saves the entire list in Session
    
        WriteControls(i, j)  ' Function Call
    
    End Sub
    
    Private Sub WriteControls(i As Integer, j As Integer)  ' Function to write button control
        While (i < j)
            Dim b As Button = New Button()
            b.ID = "b" + i.ToString()
            b.Text = b.ID
            b.ViewStateMode = UI.ViewStateMode.Enabled
            Panel1.Controls.Add(b)
            i = i + 1
        End While
        Session("click") = DirectCast(Session("click"), Integer) + 1
    End Sub
    
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then          
            Session("click") = 0   ' Stores the no. of Clicks of the button
        End If
    
    End Sub
    
    ' Output
    ' If I press three times button then there will be 30 buttons
    b0 b1 b2 b3 b4 ............................................... b29
    20 30
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Example 1: <asp:Panel Visible=false runat=server> <asp:TextBox ID=textbox runat=server /> </asp:Panel> Here, textbox.Visible returns false
I have a asp.net project, and in my design page I have some asp:Label
I was asked to design an ASP.NET website and run it on Windows Server
I was wondering how to design this best.. On my ASP.NET MVC application I
Got this design issue with JSF + Spring :- I got a datatable on
I keep running into this design problem, and I'm not happy with my solution
I need to make this design: http://www.stephburningham.com/lmg/ into a joomla template but I've never
I have this design which I cannot seem to get right, I would like
How would I draw up this design in a database? A product can be
I have tough time making this design decision. I could go with traditional new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.