Help in composite control

F

Faizan Ahmed

Hello all,
I've been stuck in this problem for a couple of days now and could'nt get
any closer to the solution.. any help will be highly appreciated..

I have a server control that i derived from DataGrid control. This custom
control also has a Microsoft IE Toolbar control which contains some toolbar
buttons

The declaration of the class is :
Public Class EnhancedBrowse

Inherits DataGrid

Protected WithEvents mFooterToolbar As New
Microsoft.Web.UI.WebControls.Toolbar


The code in the OnInit method is
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)

dim table As New HtmlControls.HtmlTable

table.Attributes.Add("runat", "server")

Dim tRow As New HtmlControls.HtmlTableRow

Dim td As New HtmlControls.HtmlTableCell

tRow.Attributes.Add("runat", "server")

td.Attributes.Add("runat", "server")

tRow.Controls.Add(td)

mHeaderToolbar.AutoPostBack = True

mHeaderToolbar.Attributes.Add("runat", "server")

AddHandler mHeaderToolbar.ButtonClick, New EventHandler(AddressOf
mHeaderToolbar_ButtonClick)

AddToolbarButtons(mHeaderToolbar, mHeaderToolbarCollection) ' This is a
method that creates buttons in the toolbar

mHeaderToolbar.Attributes.Add("id", "mHeaderToolBar")

td.Controls.Add(mHeaderToolbar)

table.Rows.Add(tRow)

Me.Controls.Add(table)

End Sub


All the events raised by the grid are captured in this control's class, but
the button click of the toolbar control is not captured in the parent
control.

I have to capture the event of the toolbar buttons and do some processing on
the grid's data.

If i add an attribute like
mHeaderToolbar.Attributes.Add("onButtonClick","MyHandler"), it does not
raises the event... i've tried overriding the OnBubbleEvent()
method of my control but it does not get events of the toolbar. some one
please help me out...

~Dejavou
 
J

John Saunders

Faizan Ahmed said:
Hello all,
I've been stuck in this problem for a couple of days now and could'nt get
any closer to the solution.. any help will be highly appreciated..

I have a server control that i derived from DataGrid control. This custom
control also has a Microsoft IE Toolbar control which contains some
toolbar
buttons ....
All the events raised by the grid are captured in this control's class,
but
the button click of the toolbar control is not captured in the parent
control.

Just as an experiment, if you add a normal Button control, are you able to
capture the events of the Button? If so, then perhaps the problem is the
Toolbar and not your control.

John Saunders
 
F

Faizan Ahmed

Thanks for replying,
I've tried to add the button in the same way as the toolbar and initially it
did'nt work, It raised some error with the control tree and view state. I
then turned my custom control's EnableViewState property to false and then
it worked, i.e. now a normal button is raising events in my control.
Still i think this is not the problem with the Toolbar. Any ways... can you
suggest any thing if i insist on using this toolbar?... and what other
options i have if i leave this toolbar, are there any other free source
toolbar controls you know off? and one more question .. y i had to turn the
EnableViewState property to false, to get the event of the button's click??

Thansks again for your help.

Regards
Faizan Ahmed
 
J

John Saunders

Faizan Ahmed said:
Thanks for replying,
I've tried to add the button in the same way as the toolbar and initially
it
did'nt work, It raised some error with the control tree and view state. I
then turned my custom control's EnableViewState property to false and then
it worked, i.e. now a normal button is raising events in my control.
Still i think this is not the problem with the Toolbar. Any ways... can
you
suggest any thing if i insist on using this toolbar?... and what other
options i have if i leave this toolbar, are there any other free source
toolbar controls you know off? and one more question .. y i had to turn
the
EnableViewState property to false, to get the event of the button's
click??

I don't know why EnableViewState should have affected anything, unless
you're adding the Button dynamically but not adding it on the initial
request and each postback.

In the absence of the Microsoft toolbar, you could write one of your own. My
favorite controls book ("Developing Microsoft® ASP.NET Server Controls and
Components" from Microsoft Press, by Nikhil Kothari and Vandana Datye
(http://www.microsoft.com/mspress/books/5728.asp)) has an example of a
ButtonBar control. I have used this as the starting point for my own
"toolbar-style" controls.

John Saunders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top