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 6080483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:04:00+00:00 2026-05-23T11:04:00+00:00

I have a fully dynamiclly generated page that has a set of linkbuttons basically

  • 0

I have a fully dynamiclly generated page that has a set of linkbuttons basically switching views in a UpdatePanel. All that is working great except for when I have a button that is generated that needs to invoke a function to manipulate the data in the Update Panel.

.aspx

<div>
    <asp:panel runat="server" ID="buttons" />

     <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"  >
        <ContentTemplate>
        </ContentTemplate>
     </asp:UpdatePanel>

</div>

Code Behind

Private Sub testpage_Init(sender As Object, e As System.EventArgs) Handles Me.Init
    For i As Integer = 0 To 5 'create a few dummy buttons
        Dim Btn As New LinkButton
        Btn.ID = "btn" & i.ToString
        Btn.Text = i.ToString
        AddHandler Btn.Click, AddressOf btn_Click
        buttons.Controls.Add(Btn)

        Dim Trgr As New AsyncPostBackTrigger 'async link them to the updatepanel
        Trgr.ControlID = Btn.ID
        UpdatePanel1.Triggers.Add(Trgr)
    Next
End Sub

Private Sub btn_Click(sender As Object, e As System.EventArgs)
    ScriptManager.GetCurrent(Me.Page).AddHistoryPoint(sender.id.ToString, sender.id.ToString, sender.id.ToString)

    UpdatePanel1.ContentTemplateContainer.Controls.Add(New LiteralControl(sender.id.ToString)) 'Show it got clicked

    If sender.id.ToString = "btn1" Then
        Dim Btn As New Button
        Btn.ID = "test"
        Btn.Text = "Click me"
        AddHandler Btn.Click, AddressOf subbtn_Click
        UpdatePanel1.ContentTemplateContainer.Controls.Add(Btn)
    End If
End Sub

Private Sub subbtn_Click(sender As Object, e As System.EventArgs)
    UpdatePanel1.ContentTemplateContainer.Controls.Add(New LiteralControl("It doesn't work"))
End Sub

So the problem is when the page_init is executed it does not know which linkbutton was selected so it never recreates the button and in turn never fires the event. I have seen people use the session to store the list of controls and/or the current frame but I don’t see that as an acceptable solution. Surely there has to be a way to do this.

Is there no way I can get the ScriptManager’s current/previous step information outside of the Navigate event?

Asp.net 4.0 with latest ajax toolkit.

Thanks for the help.

  • 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-05-23T11:04:01+00:00Added an answer on May 23, 2026 at 11:04 am

    This is (I think) one of the fundamental flaws with webforms, and the ways of dealing with it are all a pain. The architecture should have included a native construct to permit event bindings to persist after a postback without recreating a control. Oftentimes you have no interest in using the control after the postback, but you are forced to track & recreate it in order to capture the event.

    I usually store a list of strings containing information that can be used to recreate all the controls in ViewState; then recreate them on LoadViewState; add them to a page as the children of a placeholder control; and remove them from the placeholder again in SaveViewState. This isn’t really that awful, it’s just tedious.

    Since you’re using an UpdatePanel you have the option of using the form field __EVENTTARGET which will contain the unique ID of the control that initiated an asynchronous postback. You may be able to extract what you need from that, and take whatever action you need based on that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page that has an HTML table generated by an ASP.NET
I have a fully working Setup project within Visual Studio 2008 that takes inputs
Here's what I have (all generated dynamically, if that makes a difference) : A
I have a table that has 100% width. It is generated dynamically with values
This is something that I have never fully grasped in .NET as to the
I have a database table on a development server that is now fully populated
This would be my issue I have a drop down that's not displaying fully.
We have a Wicket app with a page that includes an embedded Youtube video.
I have a dynamically generated html page which is designed to be printed. I
I have a page with a lot of dynamically generated check boxes on it.

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.