I am trying to pass the objeto sender
to an event that does not receive parameters, I need the sender object in order to generate the information
This is the event sent by the sender object:
protected void DButton(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showAndHide();", true);
enable = true;
DynamicButton();
}
and this is the event I want the sender object to receive
protected void DynamicButton()
{
Button Btn_clic = (Button)sender;
var name = Btn_clic.Text;
List.ListUsers listArea = new List.ListUsers();
List<Data.Area> Area = listArea.AreaList();
List<Data.Area> ListOfEquiposOk = Area.Where(x => x.AREA == NECESITO EL EVENTO PARA CAMBIAR ESTE DATO ---> "ENG" && x.STANDBY == 0).ToList();
List<Button> Botones = new List<Button>();
var TeamFCH = ListOfEquiposOk.Select(x => x.TEAM).Distinct().ToList();
foreach (var team in TeamFCH)
{
Button newButton = new Button();
newButton.CommandName = "Btn" + Convert.ToString(team);
newButton.ID = "Btn_" + Convert.ToString(team);
newButton.Text = team;
newButton.CommandArgument = "ENG";
newButton.Click += new EventHandler(newButton_Click);
pan1.Controls.Add(newButton);
Botones = pan1.Controls.OfType<Button>().ToList();
Botones.Add(newButton);
newButton.CssClass = "btn-primary outline separate";
}
}
and that's how everything starts
public partial class Dashboard : System.Web.UI.Page
{
static bool enable = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DynamicButton();
}
else if(enable)
{
DynamicButton();
}
}