user control load event does not fire on postback

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marcel Balcarek

    user control load event does not fire on postback

    I create a user control dynamically:
    Dim newCriteriaCont rol As CriteriaTextBox UserControl =
    CType(Me._page. LoadControl("Cr iteriaTextBoxUs erControl.ascx" ),
    CriteriaTextBox UserControl)

    myContainer.Add (newCriteriaCon trol)

    and the user control's load event executes on initial executon of the page.
    On a POST of the same page, the control is added as above, but the load
    event is not firing, nor is prerender.

    What's going on? How can I get code to execute in the user control on a page
    postback?

    Marcel






  • Ashish M Bhonkiya

    #2
    Re: user control load event does not fire on postback

    Hi Marcel Balcarek,

    I have Tried to reproduce your problem but am not facing any problems. i
    have created one usercontrol and am dynamically adding it in the page load
    event of the page and the event is getting fired for me.

    you may check this code if you are missing something.

    UserControls' Page Load
    if (Page.IsPostBac k)
    {
    Response.Write( "This is a PostBack... haahaah")
    }
    else
    {
    Response.Write( "This is not a PostBack...")
    }

    Page's Page_Load
    Dim myControl As CriteriaTextBox UserControl =
    CType(Me.LoadCo ntrol("Criteria TextBoxUserCont rol.ascx"),
    CriteriaTextBox UserControl)
    PlaceHolder1.Co ntrols.Add(myCo ntrol)

    PS: also check that you are not missing to add the user control in the
    page_load's Postback.

    Regards
    Ashish M Bhonkiya




    "Marcel Balcarek" <marcel_balcare k@REM-OVEMEtoxicall.c om> wrote in message
    news:%23nnyn8WL EHA.4080@TK2MSF TNGP12.phx.gbl. ..[color=blue]
    > I create a user control dynamically:
    > Dim newCriteriaCont rol As CriteriaTextBox UserControl =
    > CType(Me._page. LoadControl("Cr iteriaTextBoxUs erControl.ascx" ),
    > CriteriaTextBox UserControl)
    >
    > myContainer.Add (newCriteriaCon trol)
    >
    > and the user control's load event executes on initial executon of the[/color]
    page.[color=blue]
    > On a POST of the same page, the control is added as above, but the load
    > event is not firing, nor is prerender.
    >
    > What's going on? How can I get code to execute in the user control on a[/color]
    page[color=blue]
    > postback?
    >
    > Marcel
    >
    >
    >
    >
    >
    >[/color]


    Comment

    Working...