custom server controls

rotsey

Newcomer
Joined
Nov 16, 2004
Messages
15
Location
Sydney, Australia
HI

I am learnig asp.net custom server controls and have a design issue problem.

I am designing a composite control that firstly display a textbox to enter a suburb and then a button that when clicked displays a list of customers in the suburb.

So in CreateChildControls sub I create a textbox and a button. I add a handler for the button. All OK.

So when user clicks the button a what to bind to a datasource and build the list. I put this in the DataBind() sub and call it from the button event handler.

Now I want to be able to have a "Prev/Next" buttons so user can page through list so I add 2 linkbuttons and add hanlders for them.

The problem is the event hanlders for the Prev/Next are not being called when user clicks them.

They are being created in the DataBind sub.

Can anyone let me know if the design is wrong or how I can get the Next/Prev link buttons to call there eventhandlers.

Thanks
Rotsey.
 
You should be creating your controls for the custom control in your render method not create child controls method.

The event handlers should always be there, you shouldn't be creating them dynamically when you databind, you simply should be hiding your list of results and previous and next buttons until the list is created at which time you would make all of those things visible.

That should make your control much simpler and easier to debug too. Good luck.
 
Back
Top