W
William French
I am triing to load a control derived from a datagrid into a composite
control so I can wrap some html around the datagrid. it renders the
html in the composite control but does not render the dervived
control. The derived control works fine on it's own. I got most of
this from an O'reilly book but having trouble figuring the details.
Any help would be greatly appreciated.
Dervived Control
-----------------------------------------
Imports System.ComponentModel
Imports System.Web.UI
<DefaultProperty("Text"), ToolboxData("<{0}:MSSDataGrid
runat=server></{0}:MSSDataGrid>")> Public Class MSSDataGrid
Inherits System.Web.UI.WebControls.DataGrid
End Class
Composite Control
------------------------------------------
Imports System.ComponentModel
Imports System.Web.UI
<ControlBuilder(GetType(MSSDataGridBuilder)), ParseChildren(False)>
Public Class MSSWrapperControl
Inherits System.Web.UI.WebControls.DataGrid
Dim grid As New MSSDataGrid()
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
output.RenderBeginTag("div")
RenderChildren(output)
output.RenderEndTag()
End Sub
Protected Overrides Sub RenderChildren(ByVal output As
HtmlTextWriter)
If HasControls() Then
' Render Children in reverse order.
Dim i As Integer
For i = 0 To Controls.Count - 1
Controls(i).RenderControl(output)
Next
End If
End Sub 'RenderChildren
Protected Overrides Sub CreateChildControls()
Controls.Add(grid)
End Sub
End Class
Friend Class MSSDataGridBuilder
Inherits ControlBuilder
Public Overrides Function GetChildControlType(ByVal tagName As
String, ByVal attributes As IDictionary) As Type
If tagName = "MSSDataGrid" Then
Dim x As MSSDataGrid
Return x.GetType
Else
Return Nothing
End If
End Function
Public Overrides Sub AppendLiteralString(ByVal s As String)
End Sub
End Class
aspx page
------------------------------------------------------------------
<%@ Register TagPrefix="uc1" Namespace="test" Assembly="test" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="test.aspx.vb" Inherits="test.test"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>test</title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="Styles.css" type="text/css" rel="stylesheet">
</HEAD>
<body topMargin="0" rightMargin="0">
<form id="Form1" method="post" runat="server">
<uc1:MSSWrapperControl runat="server" id="msswrappercontrol">
<uc1:MSSDataGrid runat="server" id="mssdatagrid"
ShowHeader="False" AutoGenerateColumns="False" GridLines="Horizontal">
<COLUMNS>
<ASP:BOUNDCOLUMN HeaderText="CustomerID" DataField="CustomerID"
/>
<ASP:BOUNDCOLUMN HeaderText="CompanyName"
DataField="CompanyName" />
<ASP:BOUNDCOLUMN HeaderText="ContactName"
DataField="ContactName" />
</COLUMNS>
</uc1:MSSDataGrid>
</uc1:MSSWrapperControl>
<asp
ataGrid id="DataGrid1" runat="server"></asp
ataGrid></form>
</body>
</HTML>
again thank you for any help that can be provided.
control so I can wrap some html around the datagrid. it renders the
html in the composite control but does not render the dervived
control. The derived control works fine on it's own. I got most of
this from an O'reilly book but having trouble figuring the details.
Any help would be greatly appreciated.
Dervived Control
-----------------------------------------
Imports System.ComponentModel
Imports System.Web.UI
<DefaultProperty("Text"), ToolboxData("<{0}:MSSDataGrid
runat=server></{0}:MSSDataGrid>")> Public Class MSSDataGrid
Inherits System.Web.UI.WebControls.DataGrid
End Class
Composite Control
------------------------------------------
Imports System.ComponentModel
Imports System.Web.UI
<ControlBuilder(GetType(MSSDataGridBuilder)), ParseChildren(False)>
Public Class MSSWrapperControl
Inherits System.Web.UI.WebControls.DataGrid
Dim grid As New MSSDataGrid()
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
output.RenderBeginTag("div")
RenderChildren(output)
output.RenderEndTag()
End Sub
Protected Overrides Sub RenderChildren(ByVal output As
HtmlTextWriter)
If HasControls() Then
' Render Children in reverse order.
Dim i As Integer
For i = 0 To Controls.Count - 1
Controls(i).RenderControl(output)
Next
End If
End Sub 'RenderChildren
Protected Overrides Sub CreateChildControls()
Controls.Add(grid)
End Sub
End Class
Friend Class MSSDataGridBuilder
Inherits ControlBuilder
Public Overrides Function GetChildControlType(ByVal tagName As
String, ByVal attributes As IDictionary) As Type
If tagName = "MSSDataGrid" Then
Dim x As MSSDataGrid
Return x.GetType
Else
Return Nothing
End If
End Function
Public Overrides Sub AppendLiteralString(ByVal s As String)
End Sub
End Class
aspx page
------------------------------------------------------------------
<%@ Register TagPrefix="uc1" Namespace="test" Assembly="test" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="test.aspx.vb" Inherits="test.test"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>test</title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="Styles.css" type="text/css" rel="stylesheet">
</HEAD>
<body topMargin="0" rightMargin="0">
<form id="Form1" method="post" runat="server">
<uc1:MSSWrapperControl runat="server" id="msswrappercontrol">
<uc1:MSSDataGrid runat="server" id="mssdatagrid"
ShowHeader="False" AutoGenerateColumns="False" GridLines="Horizontal">
<COLUMNS>
<ASP:BOUNDCOLUMN HeaderText="CustomerID" DataField="CustomerID"
/>
<ASP:BOUNDCOLUMN HeaderText="CompanyName"
DataField="CompanyName" />
<ASP:BOUNDCOLUMN HeaderText="ContactName"
DataField="ContactName" />
</COLUMNS>
</uc1:MSSDataGrid>
</uc1:MSSWrapperControl>
<asp
</body>
</HTML>
again thank you for any help that can be provided.