DevExpress Exception Solution - The target "X" for the callback could not be found or did not implement ICallbackEventHandler
2010-07-07 15:20
2556 查看
Description
I've loaded a control dynamically and got the "The target "X" for the callback could not be found or did not implement ICallbackEventHandler" error for the control itself or for one of its child controls. Why?Solution
When the control is loaded dynamically, it should meet the following requirements:1) It should be loaded on each request.
2) If this control has child controls, it should have a static ID.
If the first condition is ignored, then the control may be lost after a callback or postback. So, the best practice is to load this control on each Page_Load.
If it is required to load it after some action only (for example, after a button is clicked), then a possible solution is to use a session or one of the session alternatives . Here's a simple example:
[C#]
protected void Page_Load(object sender, EventArgs e) { if (Session["isControlLoaded"] != null) { AddControl(); } } protected void ASPxButton1_Click(object sender, EventArgs e) { AddControl(); Session["isControlLoaded"] = "loaded"; } public void AddControl() { Control control = LoadControl("MyControl.ascx"); control.ID = "MyControl"; form1.Controls.Add (control); }
[VB.NET]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not (Session("isControlLoaded") is Nothing) AddControl(); End If End Sub Protected Sub ASPxButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ASPxButton1.Click AddControl() Session("isControlLoaded") = "loaded" End Sub Public Sub AddControl() Dim control As Control = LoadControl("MyControl.ascx") control.ID = "MyControl" form1.Controls.Add (control) End Sub
The second requirement is imposed for the reason that all child controls in the NamingContainer have IDs, which are based on the ID of this container.
For example, if there is an ASPxGridView within the MyControl.ascx (see the previous example) with the static ID = "ASPxGridView1", then its final ID will look like this:
MyControl_ASPxGridView1
If you do not set the static ID for MyControl, then it will be assigned dynamically and changed in each request. Accordingly, the id of the grid will be also changed and this fact may cause the situation when the control someID_ASPxGridView1 that sent a callback is "disappear" because it got a new ID during a request.
相关文章推荐
- "The target '__Page' for the callback could not be found or did not implement ICallbackEventHandler."的解决办法
- Solution For "could not be located or a different control is assigned to the same ID after postback"
- 安装11.2.0.3时,OUI的log报错:"OUI-10066:Not All The Dependencies For The Component ... Could Be Found"
- The controller for path '/favicon.ico' could not be found or it does not implement the IController interface./r/nParameter name:
- An EJB Exception:The user-provided class "XXXX" needed by the EnterpriseBean could not be found or loaded.
- The plugin 'org.apache.maven.plugins:maven-eclipse-plugin' does not exist or no valid version could be found 解决
- Application "XXX" could not be found in the registry的解决办法
- 在keychain tool里,Request a certificate时,出错''The specified item could not be found in the keychain"
- Exception in thread "main" java.sql.SQLException: Connections could not be acquired from the underly
- Eclipse建立Web项目出现 Runtime "Apache Tomcat v7.0" is invalid. The JRE could not be found. Edit the serve
- Eclipse Wowza 插件报 "The builder launch configuration could not be found" 错误的解决办法
- solution for "log4j:WARN No appenders could be found for logger"
- Application "XXX" could not be found in the registry的解决办法
- DirectoryNotFoundException: Could not find a part of the path "……"
- 访问Storm ui界面,出现org.apache.storm.utils.NimbusLeaderNotFoundException: Could not find leader nimbus from seed hosts ["master" "slave1"]. Did you specify a valid list of nimbus hosts for confi的问题解决(图文详解)
- LoadLibrary("TestOCX.ocx") failed-The specified module could not be found
- MSbuild failure: error CS0246: The type or namespace name 'DataLoader_Accessor' could not be found
- VS2010 & Qt,版本Release时:Debugging information for "project.exe" cannot be found or does not match.
- The file or Assembly "BMC.arnettoc.dll" or a dependency could not be found.
- mybatis 引用对象属性映射错误 or could not be found for the javaType (xxx.model) : jdbcType (null) combination.