Question

In: Computer Science

Suppose an application’s GUI has two TextBox controls named inputTextBox and outputTextBox. Write C# statement(s) that...

Suppose an application’s GUI has two TextBox controls named inputTextBox and outputTextBox. Write C# statement(s) that display the text entered by the user in the inputTextBox to the outputTextBox.

Write a statement for shifting focus to the textbox control nameTextBox.

Assume that we have a listbox control stateListBox. Add the item “Florida” to the list box.

Solutions

Expert Solution

Find the following steps as per required :

Step 1:

Create a new website with language as C#

Step 2 :

The project looks like as shown below in attached screenshot :

Step 3:

From the Toolbox shown in the figure add the controls . Just drag and drop the control in the design view as shown in the attached screenshot with explanation

Step 4 :

Now click on the source view . Add the code as shown below :

We are adding one textbox named inputTextBox . Another named outputTextBox as shown below :

<asp:TextBox ID="inputTextBox" name="inputTextBox" runat="server" AutoPostBack="true" OnTextChanged="inputTextBox_TextChanged"></asp:TextBox>

<td><asp:TextBox ID="outputTextBox" name="outputTextBox" runat="server" AutoPostBack="true"></asp:TextBox></td>

<asp:ListBox ID="ListBox1" runat="server">
<asp:ListItem>Georgia</asp:ListItem>
</asp:ListBox>

Step 5 :

As per required , we need to add an event i.e onTextChanged fwhen inputTextBox is changed . This will invoke the method named inputTextBox_TextChanged when text in the inputTextBox is changed as shown in below figure

<asp:TextBox ID="inputTextBox" name="inputTextBox" runat="server" AutoPostBack="true" OnTextChanged="inputTextBox_TextChanged"></asp:TextBox>

Step 6:

To display the entered text in the outputTextBox , we need to use below code . I.e assigning the value of inputTextbox to outputTextbox with the following command :

// Assigning value

outputTextBox.Text = inputTextBox.Text;

Step 7 : Adding Focus to nameTextBox

Using below command add focus to nameTextBox

// Adding focus to nameTextBox
nameTextBox.Focus();

Step 8 : Adding item to list box

To add an item to list box we need to use items.Add

Code is as below :


// Adding item to list box
ListBox1.Items.Add("Florida");

Step 9: Run the Program :

Initial screenshot which displays the textboxes , list control as required .

Step 10 :

Enter text in the input textbox . Then the entered text is shown in the Output Text box . The focus is changed to the nameTextbox . And the item Florida is added to the List as shown in the below attached screenshot :

Step 11 : The final code is as below :


Related Solutions

JAVA program. Write two public classes (named exactly), TextBox and TextBoxTester.  TextBox contains the following overloaded static...
JAVA program. Write two public classes (named exactly), TextBox and TextBoxTester.  TextBox contains the following overloaded static methods called textBoxString. This method returns a String value. public static String textBoxString (int side) The returned String value, when printed, displays as the outline of a square of side characters. The character you use is up to you. Don't forget that '\n' will force a newline character into the returned String. For example, let's assume I want to use * as the character...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user to enter the three examinations ( test 1, test 2, and test 3), homework, and final project grades then calculate and display the overall grade along with a message, using the selection structure (if/else). The message is based on the following criteria: “Excellent” if the overall grade is 90 or more. “Good” if the overall grade is between 80 and 90 ( not including...
Write a MIPS program that executes the statement: s = (a + b) – (c +...
Write a MIPS program that executes the statement: s = (a + b) – (c + 101), where a, b, and c are user provided integer inputs, and s is computed and printed as an output. Answer the following: a. Suppose the user enters a = 5, b = 10, and c = -30, what is the expected value of s? b. Which instruction in your program computed the value of s and which register is used? c. What is...
Write a user defined function named “findTwosComplement” in C++, which will find 2’s complement of a...
Write a user defined function named “findTwosComplement” in C++, which will find 2’s complement of a signed number. Input must be passed by reference to the function and it will return the answer. There is no need to call this function anywhere. You can use following operators only: <<>> ~ & ^ | Decimal
Write a subroutine named swap in C thatswaps two nodes in a linked list. The first...
Write a subroutine named swap in C thatswaps two nodes in a linked list. The first node should not be able to change places. The nodes are given by: Struct nodeEl { int el; struct nodeEl * next; }; typdef struct nodeEl node; The list header (of type node *) is the first parameter of the subroutine. The second and third parameters consist of integers and are the places in the list where the nodes are to change places. The...
Two candidates: a populist named T and a woman named C, are competing for the presidency...
Two candidates: a populist named T and a woman named C, are competing for the presidency of a small country with a population of 5 people eligible to vote (being T and C part of this population). each candidate votes for himself with certainty. One of the three people will vote for candidate C with certainty. the other two voters, let's say people X and Y, are undecided. each has a 40% chance of voting for T (and 60% of...
Complete the following C++ tasks: a. Design a class named BaseballGame that has fields for two...
Complete the following C++ tasks: a. Design a class named BaseballGame that has fields for two team names and a final score for each team. Include methods to set and get the values for each data field. Create the class diagram and write the pseudocode that defines the class. b. Design an application that declares three BaseballGame objects and sets and displays their values. c. Design an application that declares an array of 12 BaseballGame objects. Prompt the user for...
2 Write a function named equivalentArrays that has two array arguments and returns 1 if the...
2 Write a function named equivalentArrays that has two array arguments and returns 1 if the two arrays contain the same values (but not necessarily in the same order), otherwise it returns 0. Your solution must not sort either array or a copy of either array! Also you must not modify either array, i.e., the values in the arrays upon return from the function must be the same as when the function was called. Note that the arrays do not...
5. Write a C++ statement or statements that will:       Print the first two digits and the  last...
5. Write a C++ statement or statements that will:       Print the first two digits and the  last two digits of any 4 digit number stored in an integer variable n.         For example, given int n = 5623, print 56    23. 6. Write  C++ statements that will align the following three lines as printed in two 20 character columns. Name                                                 Years President Abraham Lincoln                                 1860-1865 Thomas Jefferson                               1801-1809 7.  Write a C++ statement or statements that will Output if a string has a length greater than 10, equal...
Define a function named "find" that accepts two input parameters: "s "and "ch". "s" is an...
Define a function named "find" that accepts two input parameters: "s "and "ch". "s" is an object of the type "string" and "ch" is a character value with the default argument of 'A'. The function looks for the character "ch" in the string  "s" and displays all the indices of its occurrences on the screen. For example, if the caller sends the values of "ABCDBGAB" and 'B' to the function for the parameters "s" and "ch", respectively, the function displays the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT