Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Catching buttons in repeaters

Reply
Thread Tools

Catching buttons in repeaters

 
 
Fraggle
Guest
Posts: n/a
 
      08-01-2003
*google wont let me post to
microsoft.public.dotnet.framework.aspnet.webcontro ls 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Z axis and simple menu buttons/image buttons Jonathan N. Little HTML 3 04-02-2007 09:57 AM
Datagrid Nav buttons and numeric buttons Jeremy Jones ASP .Net 1 03-22-2007 08:00 AM
Catching events from buttons in dynamic table tbTigern@newsgroups.nospam ASP .Net Web Controls 1 06-12-2006 08:21 AM
Image Buttons/Buttons not responding =?Utf-8?B?QmVu?= ASP .Net 1 07-06-2005 07:34 AM
2 buttons but want enter key in textbox to execute one buttons' click event? Roger ASP .Net 1 05-20-2005 09:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57