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

  • Home
  • SEARCH
  • 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 4102470
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:49:52+00:00 2026-05-20T20:49:52+00:00

The Repeater control in the following test case contains two runat=server DIVs . Each

  • 0

The Repeater control in the following test case contains two runat=”server” DIVs. Each one of them gets a TextBox appened to them through the ItemCreated event of the Repeater. Both of the have AutoPostBack=True, and TextChanged event wired to txt_TextChanged. However, only the TextBox from the first level properly points to the event on the postBack of the page. The second level TextBox also causes the postBack to occur, but its value does not persist in the VIEWSTATE as well as the event does not fire.

Here’s a direct link to the test case in a .zip file (uploaded to my personal website), as well as all the code needed. The project is built in VS2010 using .NET Framework 4, but the problem also exists in 1.1, 2, and 3.5.

Anybody has any ideas on what is wrong and how to make this work?

ASPX

<asp:Repeater ID="rep" runat="server">
    <ItemTemplate>
        <!-- first level works -->
        <div id="divOutside" runat="server">
            <!-- second level doesn't work -->
            <div id="divInside" runat="server"></div>
        </div>
    </ItemTemplate>
</asp:Repeater>

Code-Behind

Public Class WebForm1
    Inherits System.Web.UI.Page

    Private Sub WebForm1_Init(sender As Object, e As System.EventArgs) Handles Me.Init
            If Not IsPostBack Then
                    Dim Table As New DataTable()
                    Table.Columns.Add("Column1")
                    Dim Row As DataRow = Table.NewRow()
                    Row("Column1") = ""
                    Table.Rows.Add(Row)

                    rep.DataSource = Table
                    rep.DataBind()
            End If
    End Sub

    Private Sub repTest_ItemCreated(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rep.ItemCreated
            ' outside
            Dim divOutside As HtmlGenericControl = DirectCast(e.Item.FindControl("divOutside"), HtmlGenericControl)
            Dim txtInput As New TextBox
            With txtInput
                    .ID = "txtInputOutside"
                    .AutoPostBack = True
                    .Text = "Event gets called, value persists accross postBack."
                    .Width = 400
            End With
            AddHandler txtInput.TextChanged, AddressOf txt_TextChanged
            divOutside.Controls.Add(txtInput)

            ' inside
            Dim divInside As HtmlGenericControl = DirectCast(e.Item.FindControl("divInside"), HtmlGenericControl)
            txtInput = New TextBox
            With txtInput
                    .ID = "txtInputInside"
                    .AutoPostBack = True
                    .Text = "Event NOT called, value is lost during postBack."
                    .Width = 400
            End With
            AddHandler txtInput.TextChanged, AddressOf txt_TextChanged
            divInside.Controls.Add(txtInput)
    End Sub

    Protected Sub txt_TextChanged(sender As Object, e As EventArgs)
    End Sub
End Class
  • 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-20T20:49:52+00:00Added an answer on May 20, 2026 at 8:49 pm

    Here’s a link to Microsoft Connect, where I reported this is an official bug:
    https://connect.microsoft.com/VisualStudio/feedback/details/652655/asp-net-bug-in-event-linking-of-2nd-level-dynamic-controls

    It contains 2 PARTIAL workarounds that work in the uploaded files section, if anybody is interested or encounters the same problem, as well as details to what I found in the Workarounds tab.

    To keep it short, it is the order of getting references to the containers and the order the TextBoxes are appended to their appropriate containers which either causes the issue or works as expected.

    But, not to forget the most important point, the only reason the first-level TextBox is there in the first place is to showcase what I want as functionality. If the first-level TextBox does not get appended at all, then both workarounds fail to provide any sort of fix. Please keep that in mind when reviewing that problem – finding a workaround that revolves around changing the order of the items is not an actual solution or a fully working workaround!

    Thanks everyone for the input!

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

Sidebar

Related Questions

I have the following repeater code: <asp:Repeater ID=repMain runat=server OnItemCommand=repMain_ItemCommand EnableViewState=false> <ItemTemplate> <dmg:testcontrol runat=server
I got a templated control (a repeater) listing some text and other markup. Each
I have a user control that contains a repeater. I use the Eval() method
I'm writing item template for repeater in separate control, and then I'm using following
I have a user control that contains a repeater. It seems that data cannot
I'm using the Repeater control on my site to display data from the database.
I have a repeater control where in the footer I have a DropDownList. In
I have a repeater control on an ASP.NET 2.0 web form. As I understanding
I'm using a repeater control and I'm trying to pass a parameter as such:
I have a .NET repeater control that is data-bound to a List. As part

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.