C
CyberMan_(MCDST!)
Hi,
I programmatically create a/some buttons:
private TableCell GenerateButtonInCell(XmlNode NodeItem)
{
Button ChoosePlanButton = new Button();
ChoosePlanButton.CommandArgument = NodeItem.OuterXml;
ChoosePlanButton.UseSubmitBehavior = false;
ChoosePlanButton.ToolTip = "Request this plan";
ChoosePlanButton.Text = String.Concat("Apply");
TableCell InnerTableCell = new TableCell();
InnerTableCell.Controls.Add(ChoosePlanButton);
return InnerTableCell;
}
I attach it/them all to the same handler:
void ChoosePlanButton_Click(object sender, EventArgs e)
{
//PERSIST THE CHOSEN PLANS ATTRIBUTES TO VIEWSTATE
Button temp = (Button)sender;
ViewState.Add("ChosenPlan", temp.CommandArgument);
}
then I try to register them pre page render thus:
override protected void OnInit(EventArgs e)
{
if (ChoosePlanButton != null)
{ ChoosePlanButton.Click += new
EventHandler(ChoosePlanButton_Click); }
base.OnInit(e);
}
but obviously I cant reference the ChoosePlanButton instance outside the
method.
How do accomplish this?
Many thanks.
I programmatically create a/some buttons:
private TableCell GenerateButtonInCell(XmlNode NodeItem)
{
Button ChoosePlanButton = new Button();
ChoosePlanButton.CommandArgument = NodeItem.OuterXml;
ChoosePlanButton.UseSubmitBehavior = false;
ChoosePlanButton.ToolTip = "Request this plan";
ChoosePlanButton.Text = String.Concat("Apply");
TableCell InnerTableCell = new TableCell();
InnerTableCell.Controls.Add(ChoosePlanButton);
return InnerTableCell;
}
I attach it/them all to the same handler:
void ChoosePlanButton_Click(object sender, EventArgs e)
{
//PERSIST THE CHOSEN PLANS ATTRIBUTES TO VIEWSTATE
Button temp = (Button)sender;
ViewState.Add("ChosenPlan", temp.CommandArgument);
}
then I try to register them pre page render thus:
override protected void OnInit(EventArgs e)
{
if (ChoosePlanButton != null)
{ ChoosePlanButton.Click += new
EventHandler(ChoosePlanButton_Click); }
base.OnInit(e);
}
but obviously I cant reference the ChoosePlanButton instance outside the
method.
How do accomplish this?
Many thanks.