Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Building Controls (http://www.velocityreviews.com/forums/f59-asp-net-building-controls.html)
-   -   custom WebControl sometimes doesn't render at design time (http://www.velocityreviews.com/forums/t757566-custom-webcontrol-sometimes-doesnt-render-at-design-time.html)

redcrystal@msn.com 03-23-2005 10:36 PM

custom WebControl sometimes doesn't render at design time
 
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


redcrystal@msn.com 03-23-2005 10:44 PM

Re: custom WebControl sometimes doesn't render at design time
 
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



All times are GMT. The time now is 07:49 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.