Ok, I have more info.
If I have the Page.LoadControl in the Sub_Load portion of the aspx page,
everything works fine. However if I load the control within an event handler
somewhere else, the control does not reload after the post back. The flow of
control should be:
User types in characters and clicks the search button
The control is loaded on the right hand side which brings up a listbox
showing the query results
The user selects an item from the list box and this updates the form fields
on the left hand side
The control with the listbox goes away
So i don't want the control to be loaded each time the aspx page is loaded,
just whenever the user clicks that search button.
How can I complete the processing within the control before reposting the
> I think something is awry with this particular page. As a test, I created
> new web form and new user control and performed the same type of procedure
> and sure enough, it calls the event handler correctly. However my original
> page is still calling the postback first. Any ideas why?
> > I have a web form which has a search tool If the user types in a few
> > and clicks the search button, it loads a user control and retrieves the
> > search results. The user then clicks on the result they want and it
> > out the remainder of the form. The user control uses the Page_Load
> > subroutine to query the database and bind to a ListBox control. This
> > fine, now I want the user to select an item in the ListBox and fire a
> > handler to update the data entry form on the web form page. However, the
> > ListBox control requires the AutoPostBack which is preventing me from
> > accessing any other event handlers. For example, if I set the
> > OnSelectedIndexChanged property of the ListBox control, it never fires
> > event before the postback occurs which causes the control to dispose.
> > I tried to override the RaisePostBackEvent but it doesn't work. Any
> > Thanks.
> > Jon