ASP.Net controls to ASP.Net web forms
ASP.Net has the ability to add controls like text boxes and labels to a form.
Let's look at the other controls for Web types that are available and see some of their common properties.
In our example, we will build one type that will have the functionality that follows.
- The user's ability to enter his name.
- A choice to pick the city in which the user is located
- The capacity of the consumer to type in a gender choice.
- A choice to choose a course that the user wishes to learn. For both C# and dot net course , there will be options.
ASP.Net web forms
Let's look in-depth at each regulation. To create the form with the above-mentioned functionality, let's add them.
Step 1)
For the ASP.Net web form, the first step is to open the Forms Designer. You'll be able to drag the controls from the toolbox to the ASP.Net web form once you do this.
To open the ASP.Net web form Builder,
Right-click the Demo.aspx file in the Solution Explorer and then right-click the Demo.aspx file.
Pick the View Designer menu option.
You will be able to see your Form Designer as shown below once you carry out the above Step.
Now let's begin to add our controls, one by one,
Regulation of Mark
In order to display a text or a message to the user on the form, label control is used. Along with other sensors, label control is usually used. Popular examples are where, along with the textbox power, a mark is added. The label provides the user with an example of what is supposed to be done in the textbox. With an example shown below, let's see how we can execute this. In accordance with the textbox controls, which will be introduced in the later section, we will use a label named 'name.' This will be used.
Step 1)
The first step is to drag the control 'mark' from the toolbox to the ASP.Net web form, as shown below.
Step 2)
Follow the following steps once the label has been applied.
Right-click the label control button to go to the Properties pane.
Choose a choice from the Properties menu in ASP.Net.
Step 3)
Change the name of the Text Property from the Properties window to Name
Similarly, the ID property value for the control is also changed to lblName. At the coding level, it becomes easier to access them by defining a meaningful ID for controls. This is illustrated below.
If you make the above adjustments, the performance below will appear.
Output:-
You can see that the name mark is shown on the ASP.Net web form.
Text Box
To encourage a user to enter any text on the ASP.Net webform application, a text box is used. With an example shown below, let's see how we can execute this. To the form in which the user can enter his name, we will add one textbox.
Step 1)
The first step is to transfer the control of the textbox from the toolbox to the .Net online training india web form, as shown below.
Below is how this will look once the Textbox control is on the shape in the designer forms.
Step 2)
You have to change the ID property once the Textbox has been inserted.
Right-click on the Textbox control and go to the Properties browser.
Then choose properties
Change the textbox's id property to txtName.
You see the following output after you make the above adjustments.
To view a list of things on the ASP.Net web form, a Listbox is used. With an example shown below, let's see how we can execute this. In order to store some city locations, we are going to add a list box to the form.
Step 1)
As shown below, the first step is to drag the list box control from the toolbox to the Web Type.
Step 2)
A separate side menu will appear after you have dragged the list box into the shape. Pick the 'Edit Objects' menu from the menu.
Step 3)
A dialogue box is now shown where you can add list items to the list box.
Click the Add button to add an object to the list.
Provide a name for the text meaning of the list item, Mumbai in our case. To add a list of things for Mangalore and Hyderabad, repeat steps 1 and 2.
Click the button for “OK”
Step 4)
Go to the Properties window and adjust the value of the control's ID property to lstLocation.
If you make the above adjustments, the performance below will appear.
Output:
You can clearly see from the performance that the list box has been applied to the form.
Button Radio
A radio button is used to display a list of things from which one can be selected by the user. With an example shown below, let's see how we can execute this. For a male/female alternative, we are going to add a radio button.
Step 1)
The first step is to drag the control 'radiobutton' from the toolbox to the ASP.Net web form. (see below image). Make sure that 2 radio buttons are added, one for the 'Male' option and the other for 'Female.'
Step 2)
Modify the 'Text' property once the radio button has been added.
Click on the 'Radio control' button to go to the Properties browser.
Adjust the Radio Button's text property to 'Guy'.
To change it to 'Female, repeat the same Step.'
Also, change rdMale and rdFemale to the ID properties of the respective controls.
If you make the above adjustments, the performance below will appear.
Output:-
You can clearly see from the performance that the radio button has been added to the shape.
Checkboxes
A checkbox is used to include a list of options where several choices can be selected by the user. With an example shown below, let's see how we can execute this. To our dot net training web forms, we will add 2 checkboxes. These checkboxes provide the user with a choice if they want to learn C# or ASP.Net.
Step 1)
The first step is to drag the control checkbox from the toolbox to the ASP.Net web form, as shown below.
Step 2)
Update the id checkbox property to 'chkASP' once the checkboxes have been inserted.
Click the Checkbox command to go to the Properties pane.
Adjust the ID properties to 'chkC' and 'chkASP' for the respective controls.
Also, modify the Checkbox control's text property to 'C#'. For the other Checkbox power, do the same and update it to 'ASP.Net'.
Adjust the checkbox's ID property to 'chkASP'
Adjust the checkbox's ID property to chkCC
If you make the above adjustments, the performance below will appear.
Output:-
You can clearly see from the performance that checkboxes have been applied to the type.
Button in ASP.Net
To encourage the user to click on a button that would then start the form processing, a button is used. With our current example, as shown below, let's see how we can enforce this. We're going to add a simple button called 'Send'. This will be used on the form to submit all the details.
Step 1)
The first step is to drag the control button from the toolbox to the ASP.Net web form, as shown below.
Step 2)
After the button has been added, press the control button to go to the Properties Window. Adjust the text property to Send from the button control. Also, change the button's ID property to 'btnSubmit'.
If you make the above adjustments, the performance below will appear.
Output:-
You can clearly see from the performance that the button was applied to the shape.
ASP.Net Case Handler
You can add events to the controls while operating with an ASP.Net webform. An occurrence is something that occurs when an operation is carried out. The clicking of a button on a form is possibly the most popular activity.
You can add code to the corresponding aspx.cs file in ASP.Net web formats. When a button is pressed on the form, this code may be used to perform such actions. This is the most popular occurrence in ASP.Net web forms in general.
We're going to make it easy. To show the name that the user entered, simply add an event to the button control. To accomplish this, let's follow the measures below.
Step 1)
You have to double-click the ASP.Net web form button first. In Visual Studio, this will pull up the event code for the bell.
When you double-click the button in the ASP.Net web forms Designer, Visual Studio will automatically add the btnSubmit Click case.
Step 2)
Let's now add code to the submit event to show the meaning of the textbox name and the user's selected position.
BtnSubmit Click(object sender,EventArgs e) Secure void
{
Answer.Write(txtName.Text +
");;"
Reply.Write(lstLocation.SelectedItem.Text +
");;"
Conclusion
I hope you reach to a conclusion about ASP.Net web controls. You can learn about other topics through .Net online training.