0

Error in CallbackUpdateSchema.Callback

BC30506 Visual Basic AND ASP.net Handles clause requires a WithEvents variable defined in the containing type or one of its base types. Callback

enter image description here

Imports DevExpress.Xpo
Imports DevExpress.Data.Filtering
Imports DevExpress.Xpo.DB

Public Class UpdateSchema
    Inherits System.Web.UI.Page

Dim uow As UnitOfWork

Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
    uow = XpoHelper.GetNewUnitOfWork
End Sub

Protected Sub CallbackUpdateSchema_Callback(source As Object, e As DevExpress.Web.CallbackEventArgs) Handles CallbackUpdateSchema.Callback
    uow.UpdateSchema()
    uow.CreateObjectTypeRecords()
End Sub

End Class

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="UpdateSchema.aspx.vb" %>

<%@  Register assembly="DevExpress.Xpo.v18.2, Version=18.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"  namespace="DevExpress.Xpo" tagprefix="dx" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>   
        <dx:ASPxButton ID="ASPxButtonUpdateSchema" runat="server" AutoPostBack="False" Text="Update Schema">
            <ClientSideEvents Click="function(s, e) {CallbackUpdateSchema.PerformCallback();}" />
        </dx:ASPxButton>
        <dx:ASPxCallback ID="CallbackUpdateSchema" runat="server" ClientInstanceName="CallbackUpdateSchema">
        </dx:ASPxCallback>

    </div>
    </form>
</body>
</html>
Ritesh Khandekar
  • 3,885
  • 3
  • 15
  • 30
Dea Ananda
  • 115
  • 1
  • 10
  • I don't think you can handle events in a class definition. Handling of events is usually done by a user of an object. Is there an overridable property you can use instead? – Robert Richter Jan 17 '20 at 03:14
  • i don't think so there is an overridable property i can use. – Dea Ananda Jan 17 '20 at 03:21
  • I'm not familiar with this class, but is the Init event raised in the constructor? If so, call MyBase.New and Page_Init in your constructor. Now I'm curious--can a constructor raise an event? – Robert Richter Jan 17 '20 at 03:24

1 Answers1

0

Use the overridable method OnInit

https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.page.oninit?view=netframework-4.8#System_Web_UI_Page_OnInit_System_EventArgs_

Events are meant for users. For sub-classing, you should use overridable methods instead.

Protected Overrides Sub OnInit(e As EventArgs)
   MyBase.OnInit()
    uow = XpoHelper.GetNewUnitOfWork
End Sub
Robert Richter
  • 278
  • 2
  • 9