Derived compound controls

Discussion in 'ASP .Net Building Controls' started by Donald Welker, Aug 19, 2004.

  1. 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?
    Donald Welker, Aug 19, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWlrZUw=?=
    Replies:
    0
    Views:
    380
    =?Utf-8?B?TWlrZUw=?=
    Nov 19, 2004
  2. Replies:
    4
    Views:
    389
    Alf P. Steinbach
    May 23, 2007
  3. Replies:
    1
    Views:
    383
    myork
    May 23, 2007
  4. Replies:
    1
    Views:
    371
    Victor Bazarov
    May 23, 2007
  5. David
    Replies:
    3
    Views:
    386
    Grizlyk
    Jan 29, 2008
Loading...

Share This Page