Is there a way to accomplish this:
I want to create a class that inherits from a usercontrol, so I can have some common functionality in a number of usercontrols. Each user control will have it's own code as well. How do I indicate the inheritance in the actual UserControl (In the aspx, and the aspx.vb). I can't get this to work. I've read about abstract classes as well, but not sure how to implement them. Does anyone know what I'm doing wrong here? Any help would be much appreciated.
example: MyUserControl.vb
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data.SqlClient
Public Class MyUserControl : Inherits UserControl
Private _Id As Integer
Private _FromAddress, _FromName As String
ReadOnly Property MailerId() As Integer
Get
If Not Context.Session("MailerId") Is Nothing Then
_Id = Context.Session("MailerId")
End If
Return _Id
End Get
End Property
Public Property FromAddress() As String
Set(ByVal Value As String)
_FromAddress = Value
End Set
Get
Return _FromAddress
End Get
End Property
Public Property FromName() As String
Set(ByVal Value As String)
_FromName = Value
End Set
Get
Return _FromName
End Get
End Property
Public Overridable Sub RenderMe()
'Code in here
End Sub
End Class
MyUserControl.ascx
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="test.ascx.vb" Inherits="LeadAuction.test" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
MyUserControl.ascx.vb
Public MustInherit Class test
Inherits System.Web.UI.UserControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put code in here
End Sub
Public Sub Overrides RenderMe()
'Put code in here
End Sub
End Class