Last post Jul 12, 2017 07:50 PM by dean4if
Jul 11, 2017 03:57 PM|dean4if|LINK
I have created a custom asp.net DataPagerField (created by Inheriting this class) and want to have this show a ReturnCommand button that can be Raised and sent back to the page where the custom DataPagerField is used to allow that page to decide how to handle
the ReturnCommand event.
I have created many custom asp.net server controls and many return their own custom events, but since the DataPagerField is defined inside (as part of) the DataPager control, I have not been able to figure out (or determine if it is possible) how to setup
my custom DataPagerField to raise the ReturnCommand event.
In other custom controls that I have created, I have been able to define my own custom events that can be handled on the page where those custom controls are defined. But, since the DataPagerField is defined inside of a DataPager, I have not been
able to determine if there is a way to Raise an event to be handled by the page where the custom DataPagerField is setup.
Thanks for any help, even if the correct answer is that it is not possible.
Jul 12, 2017 07:50 PM|dean4if|LINK
Found the answer:
In my custom control inherited from DataPagerField, I define a Public Event (in my case, ReturnCommand with a type of CommandEventHandler). In my custom control, the logic to handle this event makes an OnReturnCommand call passing a New CommandEventArgs
having a CommandName of "Return". In the OnReturnCommand procedure, I do the RaiseEvent call of the ReturnCommand event, including the CommandEventArgs data.
In the page where I define the custom DataPagerField mark-up, intellisense now shows the OnReturnCommand option where I define the procedure to handle my event (in my case it is NavPagerItem_ReturnCommand) and this has the procedure signature of a LinkButton
where the e parameter is of type CommandEventArgs.
Clicking my Return button now invokes the NavPagerItem_ReturnCommand procedure ... Woo Hoo