UserControl, button click and Page_Load?

O

Olav Tollefsen

I have a rather fundamental ASP.NET question.

On my page I have a search text box for user input, a button (which invokes
a event handler on the page) and a user control to display the results. The
button event handler will get a data set from a database and then calls a
method in the user control to transfer the dataset to the control. Then it
should render it's results to the page.

My problem is that the order of events after the button is clicked is like
this:

1) Page_Load for the ASP.NET page is called
2) Page_Load for my user control is called (which is not initialized with
the search results yet)
3) Button event handler is called

The problem is that the user control should be rendered after the button
event has been executed and not before.

What is the correct method to achieve this?
 
S

Steve C. Orr [MVP, MCSD]

Instead of the load event you could move your code to the PreRender event ,
which happens after all the control events. So by
then everything should be initialized properly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top