Thursday, 15 March 2012

c# - Object reference not set to an instance of an object- Delegates -


I want to give value to the aspx page with user control. I am trying to use events and representatives for this. But, I do not set the object reference on an instance error.

Then, when using usercontrol, I should click on the image, the value must be passed

  Mainpage.aspx Secure Zero Page_load (Object Sender, EventErgus E) { Shieldcom (); } Zero MyParentMethod (string id) {// DO} Secure void ShoudldCome () {userControlPage G = new userControlPage (); G.eventName + = New userControlPage.abcDel (MyParentMethod); UserControlPage.ascx Public Representative abcDel (string ID); Public event ABCDL event nomination; Make secure zero calls () {eventName (id); // I get id = 7 here // Error: object is not set for an instance of reference object} Protected Zero OnRowCommand (Object Sender, GridViewCommandEventArgs e) {var id = e.CommandArgument; Id = id.ToString (); CallHere (); }    

This code requires a lot of correction but start with this simple thing: < / P>

  if (eventName! = Tap) eventName (id);  

It is not known where the ID is coming from, but there is a check to prevent the nullification exception if no one is registered for this incident.

The code was not created:

  g.eventName + = new userControlPage.abcDel (MyParentMethod);  

And you call out,

Then you have a problem, because nobody has registered yet.


No comments:

Post a Comment