J
Jim Butler
We have a set of web server controls that inherit directly from their parent
web server control and implement INamingContainer. We need our code to be
508 compliant but are having trouble with the FindControl method in
AddAttributesToRender does not find the AssociatedControlID. Our test label
class is completely devoid of custom [rendering] code. We use the
INamingContainer within our web server controls for unique id generation for
those controls when nested within user controls and so fourth. Problem when
the code is rendered, an Exception is generated like the one below.
System.Web.HttpException: Unable to find control with id 'hospital_id2' that
is associated with the Label 'lbl_hospital_id2'.
at System.Web.UI.WebControls.Label.AddAttributesToRender(HtmlTextWriter
writer)
at System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter
writer)
at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
at .... for brevity
From this aspx code
<form runat="Server">
<bl:TestLabel id="lbl_hospital_id2" Text="Hello World22"
AssociatedControlID="hospital_id2" runat="server" />
<bl:TestLabel id="hospital_id2" Text="Hello World2222" runat="server" />
</form>
Public Class TestLabel
Inherits System.Web.UI.WebControls.Label
Implements System.Web.UI.INamingContainer
Private Sub TestLabel_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
Dim x As String = ""
End Sub
End Class
Thanks in advance,
Jim Butler
web server control and implement INamingContainer. We need our code to be
508 compliant but are having trouble with the FindControl method in
AddAttributesToRender does not find the AssociatedControlID. Our test label
class is completely devoid of custom [rendering] code. We use the
INamingContainer within our web server controls for unique id generation for
those controls when nested within user controls and so fourth. Problem when
the code is rendered, an Exception is generated like the one below.
System.Web.HttpException: Unable to find control with id 'hospital_id2' that
is associated with the Label 'lbl_hospital_id2'.
at System.Web.UI.WebControls.Label.AddAttributesToRender(HtmlTextWriter
writer)
at System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter
writer)
at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
at .... for brevity
From this aspx code
<form runat="Server">
<bl:TestLabel id="lbl_hospital_id2" Text="Hello World22"
AssociatedControlID="hospital_id2" runat="server" />
<bl:TestLabel id="hospital_id2" Text="Hello World2222" runat="server" />
</form>
Public Class TestLabel
Inherits System.Web.UI.WebControls.Label
Implements System.Web.UI.INamingContainer
Private Sub TestLabel_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
Dim x As String = ""
End Sub
End Class
Thanks in advance,
Jim Butler