I am creating one button on a page dynamically. Now I want to use the button click event on that button.
How can I do this in C# ASP.NET?
public form1() { foreach (Panel pl in Container. Components) { pl. Click += Panel_Click; } } private void Panel_Click(object sender, EventArgs e) { // Process the panel clicks here int index = Panels. FindIndex(a => a == sender); ... }
Creating a C# Button To create a Button control, you simply drag and drop a Button control from Toolbox to Form in Visual Studio. After you drag and drop a Button to a Form, the Button looks like Figure 1. Once a Button is on the Form, you can move it around and resize it.
This example demonstrates how do I add a button dynamically in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.
How can I call SubGraphButton_Click(object sender, RoutedEventArgs args) from another method? private void SubGraphButton_Click(object sender, RoutedEventArgs args) { } private void ChildNode_Click(object sender, RoutedEventArgs args) { // call SubGraphButton-Click(). }
Button button = new Button(); button.Click += (s,e) => { your code; }; //button.Click += new EventHandler(button_Click); container.Controls.Add(button); //protected void button_Click (object sender, EventArgs e) { }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With