Monday, May 30, 2016

Assignment 06 on Cookies, Hidden Fields, and Sessions

Cookies

Cookies are used to store text files on the local machine that will same some of the data from the webpage and then are used to keep certain information about the users selections or other data when they visit that website again.  Cookies can be set to have an expiration date to expire and then that simple text file is not valid anymore.

When creating a cookie in ASP.Net, you will need to create the cookie object that creates a cookie under any name that you choose to have. 
Then you will want that value to have a it be set to some textbox, check box, or radio button value be stored in that cookie object.
Once that value is set to what you want to place in the cookie, you will need to now create the cookie by using the Response.Cookies.Add()


Session

Session are like cookies but they expire sooner than later, as in leaving the webpage, or in a matter of minutes you will have to redo whatever you were doing on that page(like logins to banking websites).

A session cookie is usually used for a single session such as storing your shopping cart or sign in status. www.allaboutcookies.org/cookies/session-cookies-used-for.html

To create a session you will need to create the name to the variable that you want to have the textbox value to be passed into it.
Then you will need to use the keyword Session with [] (square brackets).


Hidden fields

Hidden fields is where the user stores variables locally that would not necessarily be passed up to the server but can stay local. 

These hidden fields can be done in asp.net by dragging from the toolbox, the hiddenfield box like a label or button, in the desired location of the webpage.
Hidden fields can't do much on their own with information to be passed into them or such, so an event need to be tied into them to make them work; like a page load event or button click.
There they are able to have any value passed into them and processed any way that you may want them to function as without showing the end user anything on their end of a webpage.


Asignment 05 on JQuery

JQuery

To do a webpage with jQuery, you will first need to get the jQuery file placed in the website folder, or linked to another hosting site that has the file.

If the file has been down loaded to the local machine, you will need to place it in the project.
For Visual Studio, right click on the project name and select add.
There in that menu under add, select new folder to make a Scripts folder name to place the file into the webpage directory to keep things organized.
You will need to add the file in manually when you add a create a folder in Visual Studio, to do that you will need to right click on the Scripts folder, and select add, and then add existing item to get the jQuery file to show.


 
Once you have the file in the Scripts folder, drag and drop the file into the head of the master page .master file.

On any other pages that you want to use jQuery on, it will be already loaded by the .master file.

To use the jQuery functions, start out by making a <script></script> tags.
In the script tags, start out by using the $ and the .ready function.  This allows the contents of the page to load before all of the functions that are in the JavaScript in the webpage become usable.



Wednesday, May 18, 2016

C# assignment 4 work

For the fourth assignment in C# this quarter, we were suppose to add onto our last weeks assignment Login Page.  Here we are to connect the login in page submit but to a database and have all of the textboxes values be stored to there.

1. To create a connection to the sql database, we need to write code to button click procedure, and have the database setup with stored procedures for accessing and modifying data in it.
2. In the that procedure, we establish a connection to the database, point to where and how to authenticate with the database when the button is click.
3. Setup what each corresponding textbox value to the proper column in the database. Then open up the connection, execute the query that you want to do, and then close the connection. (as seen below of what the code could look like)

 

Once the code is written, you are ready to test your code that connects the web form to the database.  There are a couple of way that you can debug your code if it does not work.  One way is putting a break point in your connection code to see if there is a problem, using the profiler in sql server is another way that you can see if any programs are access the database.

For the debugger in Visual Studios.

1. Place a break point in your button click  towards to the top to see how far you can go down the lines of code.
2. Open the up that web form page and click on the button to start the debugger.
3. Use F11 to walk through your code line by line as shown below.


For using the profiler in SQL Server.

1. Open up SQL Server Management Studio.
2. Go to the Tools menu and select SQL Server Profiler from the menu.
3. Create a new trace to have the database watches for applications that connect to the database and show details about it.
4. Select which database you want to watch.
5. Then the trace properties box opens up to setup what you want to watch.



6. You may want to go to Events Selection tab to filter out report server.
7. Run your trace and see if your web form is connecting to correct database.
8. Here in the trace program you can see what stored procedure was used, and what the values were that were written into the database rows.