Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > rendering derived control from composite control

Reply
Thread Tools

rendering derived control from composite control

 
 
William French
Guest
Posts: n/a
 
      12-02-2003
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>
<aspataGrid id="DataGrid1" runat="server"></aspataGrid></form>
</body>
</HTML>


again thank you for any help that can be provided.
 
Reply With Quote
 
 
 
 
Wayne
Guest
Posts: n/a
 
      12-03-2003
See if this will help you figure out your problem, I am doing my a little
different, the code is VB.NET but it may help.

Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
_Password.ApplyStyle(_TextBoxStyle)
_Password.RenderControl(output)
End Sub

Protected Overrides Sub CreateChildControls()
Controls.Clear()

_Password = New TextBox
_Password.TextMode = TextBoxMode.Password
_Password.ID = "txtPassword"
Me.Controls.Add(_Password)
End Sub




"William French" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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>
> <aspataGrid id="DataGrid1" runat="server"></aspataGrid></form>
> </body>
> </HTML>
>
>
> again thank you for any help that can be provided.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 01:44 PM
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 12:07 AM
Composite control - sub control as a property not rendering Bob Jones ASP .Net Web Controls 4 04-09-2007 07:47 PM
Losing Composite Control property that another Composite Control ... Chad ASP .Net Building Controls 0 02-01-2005 09:01 PM
Possible to create a composite control that has a child control that is a validator that validates the composite control itself? Jonathan Eric Miller ASP .Net Building Controls 2 07-22-2004 10:58 PM



Advertisments