Create User Control Event Handler in .designer file RRS feed

  • Question

  • User1616507742 posted

    Hi Everyone

    I'm attempting to reuse a component that worked successfuly in VS2017, in VS2019..

    It provides paging for Repeater Controls. In VS2017 this just worked. There's a DLL that goes into the bin folder and I can then use it. In this case, I have my own custom control that relies on it.

    I dragged my ASCX file (which uses the component) into VS2019 and it threw errors all over the place because, I think, the designer file didn't exist.

    I've created the control afresh in VS2019 and pasted in the code, so now, the code behind can "see" the controls in the ASCX. However there's one part VS2019 doesn't like and it's this:

                //Runs on all postbacks
                rptDocuments.FetchingData += new EventHandler<PageEventArgs>(rptDocuments_FetchingData);

                //Runs on every page load/posback
                rptDocuments.PreRender += new EventHandler(rptDocuments_PreRender);

    The name "rptDocuments_FetchingData" does not exist in the current context

    The name "rptDocuments_PreRender" does not exist in the current context

    These are not referring to the presence of "rptDocuments" which it can see. They're referring to the unknown event handler which it can't. In VS2017 this just worked. The identical code does not work in VS2019.

    I'm just guessing that I need to declare that in the designer file, adding the code by hand, so as to delegate that event handler to the one in the component I'm using.

    Does anyone know if that's right and how to do that?



    Wednesday, March 17, 2021 11:49 AM

All replies

  • User1616507742 posted

    Sorry to waste people's time. I've finally managed to work this out :)

    Wednesday, March 17, 2021 12:07 PM