Handles clause requires a WithEvents variable RRS feed

  • Question

  • User-1636525995 posted


    i add a Update Parameter in sql connection property that updates the data like this:


    <asp:Parameter Name="BookID" />

    <asp:Parameter Name="BookTitle" />

    <asp:Parameter Name="BookType" />

    <asp:Parameter Name="BookDescription" />

    <asp:Parameter Name="DownloadUrl" />

    <asp:Parameter Name="UserId" />

    </UpdateParameters> after select parameters. In browser the withevent error occurs

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

    Source Error:

    Line 4:  
    Line 5:  
    Line 6:      Protected Sub EditProfileDataSource_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles UserProfileDataSource.Selecting
    Line 7:          ' Get a reference to the currently logged on user
    Line 8:          Dim currentUser As MembershipUser = Membership.GetUser()

    Please give me the solution for this.

    thank you


    Sunday, May 4, 2008 6:05 AM


  • User2032526919 posted


    do you have UserProfileDataSource control on the Page (you have EditProfileDataSource_Selecting which handles UserProfileDataSource.Selecting)? And is this EditProfileDataSource_Selecting method wired in aspx using OnSelecting="EditProfileDataSource_Selecting" or in code with Handles. Point is that not both are needed, they are optional ways to wire an event handler. if you already have OnSelecting="...", you don't need the Handles clause. If you have only Handles, check that it is set to handle correct control's event.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 4, 2008 12:15 PM