in Education by
I know the answer is probably really obvious, but I'm having a complete brain fart here. What I want to do is have a simple form with two buttons. The first button shows a message saying "1". After clicking the second button, the first button says "2" when clicked. After clicking the second button again, it goes back to saying "1". Having learned programming with javascript, I'm still thinking in javascript. My first train of thought was: myButton.onclick=... After that the only thing I could think of was to have a conditional inside the first button's click function and use the second button's click to change a boolean... Is there a better way to do this? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Make button2 change the method which is called when button1 is clicked: private void button1_Click(object sender, EventArgs e) { Text = "1"; } private void button1_Click2(object sender, EventArgs e) { Text = "2"; button1.Click -= button1_Click2; button1.Click += button1_Click; } private void button2_Click(object sender, EventArgs e) { button1.Click -= button1_Click; button1.Click += button1_Click2; }

Related questions

0 votes
    I'm making a game as an android app in which the user clicks on buttons to change its color and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    Which of these methods will respond when you click any button by mouse? (a) mouseClicked() (b) mouseEntered( ... Event Handling of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    click on the_ button to select different styles for the workspace area? Fill in the blanks Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    Click on the______ button to change the selected text to dark thick font style Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    what happens when you click on the following in costume tab:edit button, copy button, x button Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    what happens when you click on the following in costume tab:edit button, copy button, x button Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
0 votes
    what happens when you click on the following in costume tab:edit button, copy button, x button Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
0 votes
    Which of these methods will respond when you click any button by mouse? (a) mouseClicked() (b) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    I want to make a new span class called "button". When the "button" is clicked, it should run ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    write about cancel,enter and insert function button in ms excel 2010 Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    Using HTML button tag, JavaScript command can be executed by using ____ function 1. "alert('Button1'); 2. "alert(Button1);" 3. "alert('Button1');" 4. "alert('Button");"...
asked Feb 26, 2021 in Technology by JackTerrance
0 votes
    In my UITableView, i need to get the event of the user, so when the cell is selected(checked), i ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I have implemented a User Control in which I have bound the DataContext to itself like this... this. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    The text data I have for a column in database in an enterprise application (uses hibernate) is huge and ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    The text data I have for a column in database in an enterprise application (uses hibernate) is huge and ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
...