none
Can custom DataPagerField Raise a custom Event RRS feed

  • Question

  • 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 the DataPager control, I have not been able to figure out (if possible) how to setup my custom DataPagerField to raise the ReturnCommand event.

    Found the solution as noted in my last post below.


    Monday, July 10, 2017 7:57 PM

Answers

  • 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

    Tuesday, July 11, 2017 4:17 PM

All replies

  • Hi Dean R. Henderson,

    Do you mean asp.net DataPager control, if so, as far as I know, DataPager field does not have event property.

    In addition, since it is asp.net control issue, I would suggest that you could post your issue on asp.net forum for suitable support.

    https://forums.asp.net/18.aspx/1?Web+Forms

    Thanks for your understanding

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 11, 2017 7:18 AM
  • 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

    Tuesday, July 11, 2017 4:17 PM