Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 3rd, 2005, 06:22 AM
Authorized User
Join Date: Aug 2004
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default PLEASE HELP - Composite Control

Hi All.

I'm trying to create a composite control. At the moment it is just a test so I have the composite control which contains a normal datagrid.

What I need to know is, from the custom control, how do I fire an OnItemCreated Event in the code behind file for the webform that the control is in.

Also, How do I pass in DatagridEventArgs to this Method.

I have attached the code I have so far.

Any help would be greatly appreciated.


=== COMPOSITE CONTROL ================================================

Imports System.ComponentModel
Imports System.Web.UI

Public Class BKDG
    Inherits System.Web.UI.WebControls.WebControl
    Implements INamingContainer

    Dim DG1 As New WebControls.DataGrid

    Public Property BKDataGrid() As WebControls.DataGrid
            Return DG1
        End Get
        Set(ByVal Value As WebControls.DataGrid)
            DG1 = Value
        End Set
    End Property

    Protected Overrides Sub CreateChildControls()
    End Sub

    Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
        output.Write("<table cellpadding=0 cellspacing=0 border=0>")
    End Sub

End Class

=== CODEBEHIND FILE ==================================================

Public Class WebForm1
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object
    Dim DB As New Database
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents MasterGrid As New BKControl.BKDG

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        MasterGrid.BKDataGrid.DataSource = DB.getDataSet("SELECT * FROM person")
    End Sub

    Public Sub SetLabel(ByVal Sender As Object, ByVal E As EventArgs)
        Label1.Text = "THIS WORKS"
    End Sub

End Class

=== WEB FORM ================================================== =======

<%@Register TagPrefix="BK" NameSpace="BKControl" Assembly="BKControl" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="BKControlTest.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
        <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
        <form id="Form1" method="post" runat="server">
            <BK:BKDG id="MasterGrid" runat="server" OnItemCreated="SetLabel" />
            <asp:Label id="Label1" runat="server"></asp:Label>


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Templates in a Composite Control dparsons ASP.NET 2.0 Professional 0 April 24th, 2008 12:28 PM
Chp.5 composite control properties studen77 BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 1 October 6th, 2006 03:35 PM
Composite Control Part 2 origjones General .NET 2 September 18th, 2006 03:28 AM
Building composite Control with Image + DDL mehdi_tn ASP.NET 2.0 Professional 1 April 12th, 2006 10:48 PM
Composite Control bmains .NET Framework 2.0 0 July 25th, 2005 12:57 PM

All times are GMT -4. The time now is 02:01 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.