Adding button to panel dynamically and getting it's parent ID
<p>I created a page where I give admin's a way to change photos info (e.g. Title, Description, etc) All the controls on the page are added dynamically because I have more than one gallery of photos.</p>

<ol>
<li><p>panel --> parent.</p></li>
<li><p>button .</p></li>
<li><p>title text box.</p></li>
<li><p>description text box.</p></li>
</ol>

<p>In every panel,  I have button that when clicked, sends the changed information to the server where the photo info is stored (Flickr). The click event for this button is added dynamically, and I want to know if is possible to get the parent of the Button I just clicked on.</p>

<p>Here is the code where I add all my controls:</p>

<pre><code> //global veriables (this is only part of the code)
 Panel panel;
 Button button;
 for (int i = 0; i &lt; photo.Length; i++) {
     photo[i] = new FlickerImages(photoSet.MediumURLS[i], photoSet.ThumbnailURLS[i], photoSet.Titles[i], photoSet.Descreption[i]);

     panel = new Panel();
     panel.ID = "panel" + i;

     button = new Button();
     button.ID = "sendDataButton" + i;
     button.Text = "send data";
     button.Click += button_Click; //adding the event

     label = new Label();
     label.ID = "editLabel" + i;

     panel.Controls.Add(label);
     panel.Controls.Add(photo[i].CurrentImage(i)); //Image control
     panel.Controls.Add(photo[i].EditTitleTextBox(i)); //TextBox control
     panel.Controls.Add(photo[i].EditCommentTextBox(i)); //TextBox control
     panel.Controls.Add(button);

     Form.Controls.Add(panel);
}
</code></pre>

<p>Here is the click event I add to all the buttons:</p>

<pre><code>void button_Click(object obj, EventArgs e) {
    Response.Write(button.Parent.ID); // i get panel10 every time this get fired.
}
</code></pre>

<p>I know this is possible with jQuery but is it possible to get the button ID in ASP.NET?</p>

<p>Sorry for my English and thanks for the help.</p>
