Stuck on this one: I have User Component that is the main content table on my web page. It simply serves as a table with decorative border and header. All content (mostly text) is placed inside this User Component on each of my web pages by accessing the UserControl's properties.
However, now I have a web page with a DataList control, and would love to place this control inside my UserControl, but am stuck.
In my previous pages, I access the UserControl's strContent property that sets the cell.text property to the text coming from my dbase, but once again, is it somehow possible to put my DataList inside this Cell or something similar.
Thanks again,
JohnHad the same problem, here's my solution:
<DefaultProperty("Title"), ParseChildrenAttribute(False), ToolboxData("<{0}:WindowPanel runat=server></{0}:WindowPanel>")> Public Class WindowPanel
Inherits System.Web.UI.WebControls.WebControlDim _title As String
Dim _cssclass As String
Dim _width As System.Web.UI.WebControls.Unit<Bindable(True), Category("Appearance"), DefaultValue("")> Property [Title]() As String
Get
Return _title
End GetSet(ByVal Value As String)
_title = Value
End Set
End Property<Bindable(True), Category("Appearance"), DefaultValue("")> Overrides Property [CSSClass]() As String
Get
Return _cssclass
End GetSet(ByVal Value As String)
_cssclass = Value
End Set
End Property
<Bindable(True), Category("Appearance"), DefaultValue("")> Overrides Property [Width]() As System.Web.UI.WebControls.Unit
Get
Return _width
End GetSet(ByVal Value As System.Web.UI.WebControls.Unit)
_width = Value
End Set
End PropertyProtected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write("<table border=""0"" cellspacing=""0"" cellpadding=""0"" style=""width:" & _width.ToString & ";border: 1px solid;border-collapse:collapse;"" class=""" & _cssclass & """>" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td style=""padding: 3px; border: 1px solid;"" class=""" & _cssclass & """>" & _title & "</td>" & vbCrLf & _
" </tr>" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td style=""padding: 3px;"">" & vbCrLf)
Me.RenderContents(output)
output.Write(" </td>" & vbCrLf & _
" </tr>" & vbCrLf & _
"</table>")
End SubEnd Class
The important thing to remember is the "ParseChildrenAttribute(False)" Statement to be able to include other controls within this custom control.
0 comments:
Post a Comment