views:

317

answers:

3

Hi I have a bit of a doozie.

I have a control with a click event attached. As far as I can see the event should be raised during postback. Things I have checked:

  • The __Eventtarget is correct.
  • The __EventArgs is correct.
  • The control can be found by using page.findControl([string in __Eventtarget]) after init, after load and during prerender.
  • I can cast the found control to IPostBackEventHandler and raise the event manually and it works fine.

What am I missing so the framework can handle this event?

Suggestions on a postcard or below please

A: 

Without the code here's a few things that may be causing problems:

  • Control is being added to the hierarchy late in the request cycle (and after the event has fired). This is problem if you're dynamically creating controls (including those in a data bound control like a Repeater, ListView, GridView, etc)
  • The event handler is being added in the code behind not the front end, eg: myButton.Click += new EventHandler(myButton_Click), and that is not being done on every request. It could be behind a logical path not executed
Slace
A: 

You have to make sure that the event is wired up in the request cycle. You can do this using the following methods:

There are other possible ways to wire up the events, e.g. you could do it manually in your code somewhere. But I've found these 2 options to be the safest so that you will be sure that your events will be fired

armannvg
+1  A: 

I found the problem: it was a third party control registering itself requiring a raise event. This information was found by using custom class inherited from Page, overrode RegisterRequiresRaiseEvent and placing a break point on entry of the overrode sub.

 Public Class Page
    Inherits System.Web.UI.Page

    Public Overrides Sub RegisterRequiresRaiseEvent(ByVal control As System.Web.UI.IPostBackEventHandler)
        If TypeOf control Is Infragistics.WebUI.UltraWebGrid.UltraWebGrid Then Exit Sub
        MyBase.RegisterRequiresRaiseEvent(control)
    End Sub

End Class
Alxwest
I'm also using Ingragistics controls and have the same issue with event handlers and dynamic controls. (these controls perfectly works in another project without IG)I have added your overrode method and placed a break point in it.But this method is not executing... could you say which another method can I use instead of that one?
Dmitry Y.