Click here to Skip to main content
15,918,889 members
Home / Discussions / C#
   

C#

 
GeneralRe: I try to aviod output parameters Pin
leckey12-Jul-06 6:18
leckey12-Jul-06 6:18 
GeneralRe: I try to aviod output parameters Pin
Ennis Ray Lynch, Jr.12-Jul-06 6:24
Ennis Ray Lynch, Jr.12-Jul-06 6:24 
QuestionNot Enough storage available mscorlib Pin
Flash-Over12-Jul-06 4:57
Flash-Over12-Jul-06 4:57 
Questioncombobox Pin
gsvgnani12-Jul-06 4:24
gsvgnani12-Jul-06 4:24 
AnswerRe: combobox Pin
Christian Graus12-Jul-06 4:29
protectorChristian Graus12-Jul-06 4:29 
AnswerClear the combo box? Pin
Ennis Ray Lynch, Jr.12-Jul-06 4:37
Ennis Ray Lynch, Jr.12-Jul-06 4:37 
QuestionBrowser - Show Friendly HTTP Error Messages Pin
nlarson1112-Jul-06 4:18
nlarson1112-Jul-06 4:18 
QuestionCatching Dynamic Button Events (C# / ASP.NET) Pin
StewartS12-Jul-06 4:11
StewartS12-Jul-06 4:11 
Hi there,

Help! Is there any consensus as to the best way to handle dynamic button clicks? The buttons are being created dynamically and conditionally placed, depending on business logic.

Our problem is that on clicking such a button, the postback calls the Page_Load but not the Button_OnClick. I notice that if I use a static button on the page, this problem does not occur, but that thwarts our business logic.

What we're trying to achieve is to add an "Edit" button. When clicked, it changes the layout of the page (i.e. the aspx page), and no longer shows this "Edit" button. Instead, "Save", "Discard", etc...).

We're trying to avoid making the buttons static, with visibility controlled by logic, as that would be such a limiting factor. e.g. we may want a dynamic array of buttons where the size of the array is unknown at design time. How would their click events be caught?

Any ideas?!
Stewart

Button EditButton;
 
protected void Page_Load(object sender, EventArgs e) {
  if (!IsPostBack) {
    setupMostOfPage(); // based on business logic
  }
 
  if (!editMode) {
    // creates and places the button in placeholder if not in editMode
    setupEditButton();
  }
}
 
EditButton_OnClick(object sender, EventArgs e) {
  // doesn't go here even when business logic creates button
 
  editMode = !editMode; 
  setupMostOfPage(); // now sets it up based on editMode
}

AnswerRe: Catching Dynamic Button Events (C# / ASP.NET) Pin
Josh Smith12-Jul-06 4:26
Josh Smith12-Jul-06 4:26 
GeneralRe: Catching Dynamic Button Events (C# / ASP.NET) Pin
jabberman12-Jul-06 4:50
jabberman12-Jul-06 4:50 
AnswerRe: Catching Dynamic Button Events (C# / ASP.NET) Pin
Christian Graus12-Jul-06 4:30
protectorChristian Graus12-Jul-06 4:30 
GeneralRe: Catching Dynamic Button Events (C# / ASP.NET) Pin
jabberman12-Jul-06 4:45
jabberman12-Jul-06 4:45 
GeneralRe: Catching Dynamic Button Events (C# / ASP.NET) Pin
Christian Graus12-Jul-06 4:47
protectorChristian Graus12-Jul-06 4:47 
GeneralRe: Catching Dynamic Button Events (C# / ASP.NET) Pin
jabberman20-Jul-06 5:22
jabberman20-Jul-06 5:22 
GeneralRe: Catching Dynamic Button Events (C# / ASP.NET) Pin
Christian Graus20-Jul-06 9:43
protectorChristian Graus20-Jul-06 9:43 
QuestionFirst record displayed in list/combobox shows "System.Data.DataRowView" instead of the value Pin
Glen Harvy12-Jul-06 3:26
Glen Harvy12-Jul-06 3:26 
AnswerRe: First record displayed in list/combobox shows "System.Data.DataRowView" instead of the value Pin
Josh Smith12-Jul-06 3:42
Josh Smith12-Jul-06 3:42 
GeneralRe: First record displayed in list/combobox shows "System.Data.DataRowView" instead of the value Pin
Glen Harvy12-Jul-06 12:40
Glen Harvy12-Jul-06 12:40 
QuestionListView Sorting Problem [modified] Pin
Abhijeet Bhamare12-Jul-06 3:17
Abhijeet Bhamare12-Jul-06 3:17 
AnswerRe: ListView Sorting Problem Pin
Josh Smith12-Jul-06 3:47
Josh Smith12-Jul-06 3:47 
AnswerRe: ListView Sorting Problem Pin
Andrew Lygin12-Jul-06 18:21
Andrew Lygin12-Jul-06 18:21 
Questionworking with Excel Pin
DJPaul12-Jul-06 3:02
DJPaul12-Jul-06 3:02 
AnswerRe: working with Excel Pin
alexey N12-Jul-06 21:24
alexey N12-Jul-06 21:24 
Questionread xml file Pin
Mohammad Daba'an12-Jul-06 2:55
Mohammad Daba'an12-Jul-06 2:55 
AnswerRe: read xml file Pin
stancrm12-Jul-06 2:57
stancrm12-Jul-06 2:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.