custom WebControl sometimes doesn't render at design time

R

redcrystal

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
 
R

redcrystal

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
 

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,054
Latest member
TrimKetoBoost

Latest Threads

Top