Saturday, January 16, 2010

Custom Controls and Problems with the Repeater ItemCommand Event!?

I am creating a custom control derived from System.Web.UI.Control.





Currently the control renders an %26lt;img...%26gt; tag with a number of attributes, one of which being added server side - Page.GetPostBackClientEvent(...).





The contorl implements System.Web.UI.IPostBackEventHandler.Rais鈥?and works fine if I place an instance of my Control on page and handle the Click event everything works fine.


However if the control is placed in an ItemTemplate in a standard Repeater then the ItemCommand event for that repeater is not fired when my control is clicked.


Standard ImageButtons etc fire the ItemCommand when placed inside one of the Repeater Templates. I have tried with ViewState on and off and a load of other things too.


If anyone has any suggestions, it would be greatly appreciated





Cheers


IanCustom Controls and Problems with the Repeater ItemCommand Event!?
I can't see certain important parts of your code, and you haven't posted all of your control's code, so it's difficult to instruct you specifically on what to do.





The short answer would be that it doesn't sound like your control is based on the ImageButton control, which should actually be the basis for your control.





Again, this is from a significant point of ignorance. If you posted your code as a text file on the Web and posted a link to the code here, I might be of more help.

No comments:

Post a Comment