CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2006
    Posts
    220

    onCommand vs onClick for Buttons

    I am wondering why there is onCommand and onClick both events for ASP:Button controls. What special purpose do they serve.

  2. #2
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: onCommand vs onClick for Buttons

    have you already read the explanation on msdn? I don't think so.
    OnCommand
    OnClick

    the main difference is that
    The Command event is raised through the control hierarchy in the form of the BubbleEvent.
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  3. #3
    Join Date
    Apr 2006
    Posts
    220

    Re: onCommand vs onClick for Buttons

    Actually I read it earlier but could not get the concept of 'BubbleEvent' clearly. Can you explain it.

  4. #4
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: onCommand vs onClick for Buttons

    this means that when a Button is nested for example in a DataGrid, then the DataGrid's OnBubbleEvent method is automaticaly called... and so forth

    Use the OnBubbleEvent method to pass an event raised by a control within the container up the page's UI server control hierarchy.
    additionally you can specify the CommandName and CommandArgument.

    OnBubbleEvent
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  5. #5
    Join Date
    Apr 2006
    Posts
    220

    Re: onCommand vs onClick for Buttons

    does it have any practical significance.

    if we have some buttons inside a GridView and every button has some CommandArguement. how can we use them. should we implement a Command event for every button of a Command Event for GridView.

  6. #6
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: onCommand vs onClick for Buttons

    here's a nice explanation of event bubbling: http://www.4guysfromrolla.com/articles/051105-1.aspx

    Quote Originally Posted by msdn
    The Command event is raised when the Button control is clicked. This event is commonly used when a command name, such as Sort, is associated with the Button control. This allows you to create multiple Button controls on a Web page and programmatically determine which Button control is clicked.
    it looks like the Command event is a general click-event handler for a group of buttons and the CommandName property helps to distinguish which button was cliked.

    but although I understand the whole concept I don't know why would I want to bubble the command event-
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  7. #7
    Join Date
    Apr 2006
    Posts
    220

    Re: onCommand vs onClick for Buttons

    Quote Originally Posted by memeloo View Post
    but although I understand the whole concept I don't know why would I want to bubble the command event-
    That is exactly the same thing I am thinking about right now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured