Last post Oct 15, 2008 04:27 PM by davidebb
Oct 15, 2008 11:41 AM|EdeJonge|LINK
I'm running into a problem using dynamically created imagebuttons. I'm using a dynamically created table to format and display information. as part of each row there are two dynamic imagebuttons, one to edit the row, another to delete the row.
On the first load the buttons respond to their click events properly, but as soon as I click on one of the linkbuttons outside of the table (read: add new row or cancel) the imagebuttons no longer fire the click event.
I've verified that a postback is occuring and made sure that the buttons are being re-created in the page_init event but they are still failing to fire.
Oct 15, 2008 02:26 PM|marcind|LINK
Is this a site that uses the Dynamic Data framework? Can you provide a simple repro?
Oct 15, 2008 02:36 PM|EdeJonge|LINK
No this site isn't using the Dynamic Data framework.
Here are samples of the creation of the imagebutton, the event that is supposed to fire when it is clicked, and an event that once is fires the imagebutton no longer works.
private TableCell GetChangeCell(string IDValue)
TableCell ChangeCell = new TableCell();
ImageButton ChangeButton = new ImageButton();
ChangeButton.ID = IDValue + "CHG";
ChangeButton.AlternateText = "CHG";
ChangeButton.ImageUrl = "~/images/pencil.png";
ChangeButton.CssClass = "Icon2";
ChangeButton.Click += new ImageClickEventHandler(ChangeButtonOnClick);
ChangeCell.ID = IDValue + "CHGCell";
the event that should fire:
public void ChangeButtonOnClick(object sender, ImageClickEventArgs e)
ImageButton ChangeButton = sender as ImageButton;
string LoadIDValue = ChangeButton.ID.Substring(0, ChangeButton.ID.Length - 3);
LoadBoardTableAdapter LoadAdapter = new LoadBoardTableAdapter();
DataTable LoadInfoTable = LoadAdapter.GetByID(new Guid(LoadIDValue));
AddNewPanel.Visible = true;
.....Fill in some textboxes here...
The event that seems to break the imagebutton:
public void AddNewButtonOnClick(object sender, EventArgs e)
// reset the field values of the addnew panel
CustomerDropDown.SelectedIndex = 0;
WorkFlowDropDown.SelectedIndex = 0;
AddNewPanel.Visible = true;
Oct 15, 2008 03:10 PM|marcind|LINK
Hi, I can't really immediately see what is wrong. Since this is a forum dedicated to Dynamic Data, you might have more luck asking in the
Web Forms forum.
Oct 15, 2008 03:29 PM|EdeJonge|LINK
It's what doesn't make any sense, from looking at it the code should work properly.
Thanks for the suggestion, that's where I originally tried to post this question but that forum requires moderator approval and this is where whomever it was decided to put my post.
Oct 15, 2008 03:58 PM|EdeJonge|LINK
Well I've sorted out atleast part of the problem. Turns out it was my browser, I've been using Firefox to test my pages. Load it up in IE7 and the events fire properly.
There's nothing I've seen that should prevent this from working in FF, if anyone has any ideas as to why this wouldn't work please let me know.
So much for keeping the site browser independent...
Oct 15, 2008 04:27 PM|davidebb|LINK
This is really the wrong forum for this, so I encourage you to post any follow up to the more general Web Forms forum.