Posted By: wacko | Sep 14th, 2005 @ 2:34 AM
page 1 of 1
Comments: 2 | Views: 4042
This must not be my week Sad I have been working on some stuff that I would like to use Anonymous Methods for but it seems that even if I just take a lonley asp button and try to tack on a Anonymous Methods in the page load event, nothing seems to happen. Is there some level of restriction on Anonymous Methods ?

EDIT: I got it working Sad darn it wasted a good thread.

but I did find something interesting that I think is worth noting and maybe its a bug but who knows... Let me post the following code :


protected void Page_Load(object sender, EventArgs e)

    {

        this.Button1.Click += delegate(object MyObject, EventArgs MyEvents){Button1.Text = "Test";};

    }



the code above does not work, it will not change the text of the button; with that being said the following code will change the button


protected void Page_Load(object sender, EventArgs e)


    {

       this.Button1.Click += delegate(object
MyObject, EventArgs MyEvents){this.Button1.Text = "Test";};


    }




noting that I had to add this in front of the button, which is wierd becuse this works


protected void Button1_Click(object sender, EventArgs e)

    {

        Button1.Text = "Test";

    }



Is this just something with Anonymous Methods and asp.net ?
footballism
footballism
I've been avalonized!
protected void Page_Load(object sender, EventArgs e)
{
      this.Button1.Click += delegate { Button1.Text = "Test";};
 }

This works here for me:p

Sheva
page 1 of 1
Comments: 2 | Views: 4042