Microsoft .NET developing tool Essay

Custom Student Mr. Teacher ENG 1001-04 5 June 2017

Microsoft .NET developing tool

2. 2. 1. 802. 11 protocol RE Item = ‘Chair’; Create a simple web application We start with creating a new project in the . NET: In the solution explorer we will get the following image: The solution explorer shows us all the resources that are used in our project. At the beginning of our web application we have just one web form which is the web page that we can work with.

Using the Toolbox shown below we can add different web components to our web form. Later on, we will see how to use some of those components in our application. In the example shown throughout this chapter we will create a simple application that performs database access. It consists of 2 web forms: the first will be a login page and second will show different data from the database.

As we said the application consists of 2 web forms so we first need to add a second web form to the application. This we can do by right clicking the project name in the solution explorer and selecting “add? add web form”. Since the application has two web forms, we will need to determine which one of them will be used as a start page. We selected WebForm1 as our start page therefore we have to set it as one.

To do this we will select WebForm1 in the solution explorer and right click on it. Selection the “set as start page” function will complete the task. Now, we should start adding objects to our application. We will add two textboxes, three labels and one button to WebForm1. Adding components to the web form is done by dragging each component from the toolbox to the web form area. Each of the different components has a name which is usually composed of the component type and a serial number e. g. textbox1. At the lower left corner of the screen you will find the properties window.

In this window we can set all of the object properties such as visibility, color, text etc. First we will change the text of the labels and the text of the button. We will do that by clicking on the object and then filling the text field in the properties window. Label1 ? welcome to my application, Label2 ? user name, Label3 ? password Button ? login. In TextBox2 properties select the Text mode = password. The next step is to allow the application to access the database. Accessing a database using the . NET is quite easy: 1. In the view menu select the Server Explorer. 2.

In the Server Explorer search for your server. 3. If your server does not appear click on and enter your server name; this will add your server to the servers list in the explorer. 4. Go to your server name? SQL Servers? your database? the table you wish to use 5. Drag the table into the web form area. 6. At the bottom of the screen 2 new objects will appear: 7. Right click the sqlDataAdapter1, select “Generate Dataset” and press OK. Now a new object will appear: 8. Right click the sqlDataAdapter1, select “Configure Data Adapter” and click next if your connection does notappear.

Select “new connection” and enter your data server details, click OK and then “next”. 9. Select “Use SQL statements” and click next. Now if you would like to change the data that you will get from the Data Adapter you can do it by using the “Query builder”. When you are done press the “next” button and finish. The dataset is an object that can contain all of the database tables making it easier to reach the data. When all of the above are done your application should look like this: Now we will move to the next stage where we will write the code for the login operation:

Double click the login button. The web form code behind will appear and you will see the Button1_Click function. In this function we will check to see if the user name entered exists in the database and if so is the password for this user name the same as the password the user had entered. Let us define some new string variables named: user, password and db_password. We will save the text from the TextBox in the above variables using the following lines: user = TextBox1. Text. ToString(); password = TextBox2.

Text. ToString(); Now we will get the data from the database using the command:sqlDataAdapter1. Fill(dataSet11); After this command the dataset will contain the entire user table. In order to select a specific user we will use the “select” command and will save the result in DataRow array in the following way: DataRow [] arr = dataSet11. user. Select(“userName ='”+user+”‘”); In arr we should have the line in the table that contains the user name we wanted and its password. At this point, by using a series of IF statements we will check if the user is allowed into the application. We will start by checking if(arr. Length! =0).

If this condition fails, it means that the user name was not found in the table. If the statement returns a true value then we will take the password from arr using this command: db_password = arr[0]. ItemArray.

GetValue(1). ToString(); Next we will check if(db_password. Equals(password))if so we will redirect the user to the application web form (“Webform2”) using the command: Response. Redirect(“WebForm2. aspx”); If not then the password that was entered was wrong. In order for the user to know what went wrong we will print out a message for the user in Label1 using this command.

Label1. Text = “User name not found”; or Label1. Text = “Wrong password”; and so on. In the next page you can see the full code for webform1. private void Button1_Click(object sender, System. EventArgs e) { String user, password, db_password; user = TextBox1. Text. ToString(); password = TextBox2. Text. ToString(); sqlDataAdapter1. Fill(dataSet11); DataRow [] arr = dataSet11. user. Select(“userName ='”+user+”‘”); if(arr. Length! =0) { db_password = arr[0]. ItemArray. GetValue(1). ToString(); if (db_password. Equals(password)) { Response.

Redirect(“WebForm2. aspx”); }.else { Label1. Text = “Login failed “; } } else { Label1. Text = “User name not found”; } } In order to begin building WebForm2, we should save all of our work and open WebForm2 from the solution explorer. In this page we will allow all the users that passed the login page to view and possibly make changes the users database through SQL commands. To this web form we need to add two textboxes, three labels, five buttons, a DropDownList and a DataGrid. After changing the location of each object and the text field in each object properties the web form should look like this.

Free Microsoft .NET developing tool Essay Sample

A

  • Subject:

  • University/College: University of California

  • Type of paper: Thesis/Dissertation Chapter

  • Date: 5 June 2017

  • Words:

  • Pages:

Let us write you a custom essay sample on Microsoft .NET developing tool

for only $16.38 $13.9/page

your testimonials