Dynamic Event Handler
-
Menu Item names are directly coming from the database and i want to attach menu item with the event handler names. so i name event handler as "handle" + item.name(value from database) + "click".I want to attach it dynamically. the code is as follows //sample code public class myclass { protected void Handle_FileMenuItem_Click(System.Object sender, System.EventArgs e) { } public bindeventhandler() { string dynamiceventhandler=""; dynamiceventhandler="Handle_" + item.Name + "_Click"; Delegate temp=Delegate.CreateDelegate(typeof(EventHandler),this,dynamiceventhandler); item.Click+=(EventHandler)temp; } } The code is throwing error. Error binding to target method. Can anyone pl explain how to solve this error... i got the idea from this url http://www.dotnet247.com/247reference/msgs/21/106638.aspx
-
Menu Item names are directly coming from the database and i want to attach menu item with the event handler names. so i name event handler as "handle" + item.name(value from database) + "click".I want to attach it dynamically. the code is as follows //sample code public class myclass { protected void Handle_FileMenuItem_Click(System.Object sender, System.EventArgs e) { } public bindeventhandler() { string dynamiceventhandler=""; dynamiceventhandler="Handle_" + item.Name + "_Click"; Delegate temp=Delegate.CreateDelegate(typeof(EventHandler),this,dynamiceventhandler); item.Click+=(EventHandler)temp; } } The code is throwing error. Error binding to target method. Can anyone pl explain how to solve this error... i got the idea from this url http://www.dotnet247.com/247reference/msgs/21/106638.aspx