Help in composite control

Discussion in 'ASP .Net Building Controls' started by Faizan Ahmed, Dec 20, 2004.

  1. Faizan Ahmed

    Faizan Ahmed Guest

    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
     
    Faizan Ahmed, Dec 20, 2004
    #1
    1. Advertising

  2. "Faizan Ahmed" <> wrote in message
    news:...
    > 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
     
    John Saunders, Dec 20, 2004
    #2
    1. Advertising

  3. Faizan Ahmed

    Faizan Ahmed Guest

    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

    "John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
    news:#...
    > "Faizan Ahmed" <> wrote in message
    > news:...
    > > 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
    >
    >
     
    Faizan Ahmed, Dec 20, 2004
    #3
  4. "Faizan Ahmed" <> wrote in message
    news:%...
    > 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
     
    John Saunders, Dec 20, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    731
  2. sleigh
    Replies:
    1
    Views:
    2,705
    sleigh
    Feb 12, 2004
  3. shapper
    Replies:
    6
    Views:
    966
    shapper
    Dec 26, 2007
  4. Chad
    Replies:
    0
    Views:
    236
  5. Mike

    Composite vs non composite Controls

    Mike, Mar 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    272
    Sundararajan
    Mar 11, 2005
Loading...

Share This Page