Catching buttons in repeaters

Discussion in 'ASP .Net' started by Fraggle, Aug 1, 2003.

  1. Fraggle

    Fraggle Guest

    *google wont let me post to
    microsoft.public.dotnet.framework.aspnet.webcontrols so thats why i
    posted here*

    I have a repeater that i want to have an ImageButton and a linkbutton
    in.

    I catch the click in the repeater using OnItemCommand=" to run a sub.

    I then cast to a button to check the CommandName=" and do what ever
    the button is meant to be doing.

    However when it comes to the cast i have to use

    Dim command As String = CType(e.CommandSource, linkButton).CommandName

    but when i added the imagebutton to the repeater and knocked the cast
    back to

    Dim command As String = CType(e.CommandSource, Button).CommandName

    It fails; i get a "Specified cast is not valid" error.

    <asp:button> <asp:Linkbutton> <asp:Imagebutton> all inherit from
    System.Web.UI.WebControls.WebControl this seems like a fairly bad way
    of going about things! I would have a general button class, and
    specialise it :(

    Whats even weirder (to me anyway) is linkbutton comes off
    System.Web.UI.WebControls.Image

    Anyway where do i go from here? do i just have to do lots of "try
    catch" to sort out which TYPE of button the user clicked, then check
    the command name then do the action?

    Thanks for any ideas

    Fragg
     
    Fraggle, Aug 1, 2003
    #1
    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. Roger
    Replies:
    1
    Views:
    655
    GreggTB
    May 20, 2005
  2. =?Utf-8?B?QmVu?=

    Image Buttons/Buttons not responding

    =?Utf-8?B?QmVu?=, Jul 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    468
    Teemu Keiski
    Jul 6, 2005
  3. Jeremy Jones

    Datagrid Nav buttons and numeric buttons

    Jeremy Jones, Mar 21, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    635
    Masudur
    Mar 22, 2007
  4. Jonathan N. Little
    Replies:
    3
    Views:
    540
    Andy Dingley
    Apr 2, 2007
  5. Catching events from buttons in dynamic table

    , Jun 2, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    127
    Prashanth G
    Jun 12, 2006
Loading...

Share This Page