custom WebControl sometimes doesn't render at design time

Discussion in 'ASP .Net Building Controls' started by redcrystal@msn.com, Mar 23, 2005.

  1. Guest

    I've created quite a few WebControls with pretty good success. I've
    made designers, data-bound controls, and so on. (Thank you to Nikhil
    Kothari and Vandana Datye for "Developing Microsoft ASP.NET Server
    Controls and Components".) I'm pretty comfortable with them now.

    However, occasionally, some of the simple composite controls do not get
    rendered at design time. All that shows up is the litte green boxed
    triangle placeholder icon that the VS.NET designer puts in the top left
    corner of all server controls. The control still shows up in the
    property browser, and there are no errors displayed. The control always
    renders property at run time. What's more, if I have several controls
    on a designer, some will render, and some won't.

    My GetDesignTimeHtml method usually looks something like this:

    Public Overrides Function GetDesignTimeHtml() As String
    Dim field As BaseField = CType(Component, BaseField)
    Dim controls As ControlCollection = field.Controls
    Dim html As String
    Dim wasBlank As Boolean = field.Text.Length = 0
    Try
    If field.ReadOnly And wasBlank Then
    field.Text = "[Value]"
    End If
    html = MyBase.GetDesignTimeHtml
    Catch ex As Exception
    html = MyBase.GetErrorDesignTimeHtml(ex)
    Finally
    If wasBlank Then
    field.Text = String.Empty
    End If
    End Try
    Return html
    End Function

    Has anyone else seen this happen and knows what causes it?

    Thanks,
    ->Alan
    , Mar 23, 2005
    #1
    1. Advertising

  2. Guest

    NEVER MIND.

    (MAN I hate it when I FINALLY decide to send a question to the group,
    only to figure out the answer moments later.)

    This was my bug. The reason the control was not showing up was that due
    to an initial state of a private member, I was not executing the
    majority of the code in the Render method. What I should have done was
    call the public Property that returns the proper initial value for that
    private member.... (slaps forehead).

    ->A
    , Mar 23, 2005
    #2
    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. John Saunders
    Replies:
    0
    Views:
    468
    John Saunders
    Aug 28, 2003
  2. Randy Smith
    Replies:
    2
    Views:
    447
    Randy Smith
    Apr 24, 2007
  3. Stef Mientki
    Replies:
    0
    Views:
    222
    Stef Mientki
    Oct 18, 2008
  4. paul reed

    Custom Control Width sometimes has a value...sometimes doesn't

    paul reed, Feb 17, 2004, in forum: ASP .Net Building Controls
    Replies:
    8
    Views:
    147
    Jeffrey Tan[MSFT]
    Feb 21, 2004
  5. Jesse Schoch
    Replies:
    2
    Views:
    131
    Jesse Schoch
    Oct 2, 2003
Loading...

Share This Page