Derived compound controls

D

Donald Welker

I have a form with various contols, each of which I want to have a View Panel
and an Edit Panel. I created a base class in TRControl.ascx.vb (there is a
TRControl.ascx that contains one line: <%@ Control Language="vb"
AutoEventWireup="false" Codebehind="TRControl.ascx.vb"
Inherits="CMSearch00.TRControl"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> ):

Public MustInherit Class TRControl
Inherits System.Web.UI.UserControl
....
Protected WithEvents pnlView As System.Web.UI.WebControls.Panel ' must
be templated or generated in each instance
Protected WithEvents pnlEdit As System.Web.UI.WebControls.Panel ' must
be templated or generated in each instance
....
Public Property View() As Boolean
Get
Return pnlView.Visible
End Get
Set(ByVal Value As Boolean)
pnlView.Visible = Value
End Set
End Property ' View

Public Property Edit() As Boolean
Get
Return pnlEdit.Visible
End Get
Set(ByVal Value As Boolean)
pnlEdit.Visible = Value
End Set
End Property ' Edit
....

Now I derive a particular user control from this in TRLineItem.ascx.vb:
Public MustInherit Class TRLineItem
Inherits TRControl
....
and I created pnlEdit and pnlView in TRLineItem.ascx but did not declare
them here.

These controls are referenced from TransReq.aspx.vb, which tries to set
their states from Page_PreRender by calling:
Private Sub dbgTurnOnTRControls(ByRef cc As ControlCollection)
' Turns on all controls, used only for debugging
Dim C As Control
For Each C In cc
If TypeOf (C) Is TRControl Then
CType(C, TRControl).Mode = TRControl.FormModes.Both
CType(C, TRControl).Edit = True ' debug
CType(C, TRControl).View = True
End If
If c.HasControls Then dbgTurnOnTRControls(c.Controls) ' recurse
Next ' C
End Sub ' dbgTurnOnTRControls

When I run this, the code executes but the Edit/View panels' Visible
properties are left in their initial states of False. Stepping through the
code I see the method entered in TRControl.aspx.vb but the actual state does
not change after the assignment. What am I doing wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top