Friday 28 February 2014

ASP .NET Controls

LinkButton Control:
The link button control behaves in exactly the same way as the button but the server will convert it into an HTML <a> tag rather than an HTML input submit control. This control appears to be a hyper link but acts like a button, unlike a hyper link it posts back by using JavaScript code.

Image Button Control:
The image button control as you might expect is a button that uses an image. Note that unlike the link button control the image button doesn't need to use any JavaScript to submit the form.
The alternate test property of image button control is exclusive to images. Alternate text was originally intended for users of text only browsers where the browser couldn't display an image the alternate text is displayed instead. Although today every major web browser is able to display images, alternate text is still useful for two reasons: one is that the search engines use alternate text to identify which keywords to attach to an image, the second reason is that visually impaired users can use alternate text in conjunction with speech detect software.
The button, link button and image button controls provide a choice of three different appearances for your buttons.

Label and Literal Control:
It doesn't have any text so a place holder is shown instead. Label and Literals controls normally display their text property on the page. Visual studio adds place holder text when the text property is empty as otherwise you wouldn't be able to the control in the design view. A label control has its text property set to 'Label' when it is created, if you clear the text property of label control it will still appear in design view with its ID property. A literal control's text property is blank when it is first created. It appears in design view with its ID property until the text property has been set. When the text property is blank the control won't acctually display any text in the user's browser. The label control is the best choice when you simply want to display text in the user's browser.

TextBox Control:
It is one of the most common controls in ASP.NET. The text box control provides the easiest way to provide users of your site to input text.

CheckBox Control:
A CheckBox is simply a box that a user can check or uncheck, you have probably seen them while browsing the internet. In the same way as all ASP .NET controls, the CheckBox is converted into HTML when the page is sent to a web browser. The checkbox control is based on the HTML input(checkbox) control but has more features. Although it is possible to use the controls from HTML category in ASP .NET, its almost always better to use ASP .NET equivalent from the standard category of the tool box.
Note if you want to create a page with lots of CheckBox choices you should be aware of the CheckBoxList control. CheckBoxList controls works very similarly to DropDown list controls except the items are shown as the check boxes instead of a drop down menu.

RadioButton Control:
Radio buttons are very similar to check boxes but only allow user to choose one option at a time. The RadioButtonList control is similar to the CheckBox list control as it allows you to create a group of radio buttons in the same way as you create a DropDown list control. In most cases the RadioButtonList control is preferable to the RadioButton control as it automatically assigns the radio buttons to the same group. The events for all of the radio buttons are also grouped together.

DropDownList Control:
DropDownList control is similar to the CheckBox and RadioButton controls. Items in DropDownList are allowed to have both a text value that is shown to the user and another value that is hidden from the user but is visible to your C# code. The value is specially used when your DropDownList control is linked to items in a database. Each item in the DropDownList control is automatically assigned a unique index number.

RequiredFieldValidator Control:
One thing you often want to do with online forms is to validate the user's input to make sure that they are entering everything correctly. Although you could validate input using a combination of C# and JavaScript. ASP .NET provides a series of controls that will automatically generate the validation code for you, the RequiredFieldValidator is one of those. A RequiredFieldValidator simply make sure that the user has entered something into the control it validates.

RangeValidator Control:
The RabgeValidator Control allows you to check that the user has entered correct type of value and allows you to restrict the value to a range. The ValidationSummary control lets you easily display a list of validation error messages to let the user know what they have entered incorrectly. The RangeValidator control is intended to restrict a value to a specific type and range.

CompareValidator Control:
The CompareValidator control is used when you want to validate by comparing one control with another.

CustomValidator Control:
The CustomValidator control allows you to enter your own JavaScript code to be used for validation.

RegularExpressionValidator Control:
The RegularExpressionValidator control allows you to validate using a regular expression.

ValidationSummary Control:
You can use a ValidationSummary control to show a list of validation problems.

Note that these are the details of the most commonly and frequently used controls. You can easily find the details of all the ASP .NET controls on the internet.

Monday 24 February 2014

ASP .NET Page Life Cycle Events

When a page request is send to a web server, the page tuns through a series of events during its creation and disposal.
Here are some important ASP .NET page life cycle events.

1) PreInit 
The entry point of the page life cycle is the pre-initialization phase called "PreInit". This is the only event where programmatic access to master pages and themes is allowed.  You can dynamically set the values of master pages and themes in this event.  You can also dynamically create controls in this event.

2) Init
This event fires after each control has been initialized. You can use this event to change initialization values for controls. The "Init" event is fired first for the most bottom control in the hierarchy, and then fired up the hierarchy until it is fired for the page itself.

3) Load
The Load event fired after the Init event. Code inside the page load event typically checks for PostBack and then sets control properties appropriately. This method is typically used for most code, since this is the first place in the page lifecycle that all values are restored. Most code checks the value of IsPostBack to avoid unnecessarily resetting state. You may also wish to call Validate and check the value of IsValid in this method. You can also create dynamic controls in this method.

4) PostBack event handling
If the request is a postback, control event handlers are called. After that, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page. (There is an exception to this sequence: the handler for the event that caused validation is called after validation.)

5) Render
This is a method of the page object and its controls (and not an event). At this point, ASP.NET calls this method on each of the page's controls to get its output. The Render method generates the client-side HTML, Dynamic Hypertext Markup Language (DHTML), and script that are necessary to properly display a control at the browser.

Note: Right click on the web page displayed at client's browser and view the Page's Source. You will not find any aspx server control in the code. Because all aspx controls are converted to their respective HTML representation. Browser is capable of displaying HTML and client side scripts.

6) Unload
The Unload event is raised after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and cleanup is performed.

Note that these are the general page life-cycle events. There are some more events like:(Init complete, PreLoad, LoadComplete etc)which you can easily find on the internet. But these six events are the basic and most important events that you must have some knowledge about.

Sunday 23 February 2014

Restricting and Sorting Data


  • Create a query to display the last name and salary of employees earning more than $12,000.
SELECT last_name, salary 
FROM employees
WHERE salary>12000;


  •  Create a query to display the employee last name and job code for employee number 176.
SELECT last_name, job_id 
FROM employees 
WHERE employee_id=176;


  • Create a query to display the last name and salary form all employees whose salary is not in the range of $5,000 and $12,000.
SELECT last_name, salary 
FROM employees 
WHERE salary NOT BETWEEN 5000 AND 12000;


  •  Display the employee last_name, Job ID, and start date of employees hired between February 20, 1998, and May 1, 1998. Order the query in ascending order by start date.
SELECT last_name, job_code, hire_date 
FROM employees 
WHERE hire_date BETWEEN '20-Feb-98' AND '01-May-98' 
ORDER BY hire_date; 


  •  Display the last name and department number of all employees in departments 20 and 50 in alphabetical order by name.
SELECT last_name, department_id 
FROM employees 
WHERE department_id IN (20, 50) 
ORDER BY last_name; 


  •  Create a query to list the last name and salary of all employees who earn between $5,000 and $12,000, and are in department 20 or 50. Label the column Employee and Monthly Salary respectively. 
SELECT last_name "Employee", salary "Monthly Salary" 
FROM employees 
WHERE salary BETWEEN 5000 AND 12000 
AND department_id IN (20, 50);


  • Display the last name and hire date of every employee who was hired in 1994.
SELECT last_name, hire_date 
FROM employees 
WHERE hire_date LIKE '%94'; 


  •  Display the last name and job title of all employees who do not have a manager.
SELECT last_name, job_id 
FROM employees 
WHERE manager_id IS NULL;


  •  Display the last name, salary and commission for all employees who earn commissions. Sort the date in descending order of salary and commissions.
SELECT last_name, salary, commission_pct 
FROM employees 
WHERE commission_pct IS NOT NULL 
ORDER BY salary DESC, commission_pct DESC;


  • Display the last names of all employees where the third letter of the name is an a 
SELECT last_name 
FROM employees 
WHERE last_name LIKE '__a%' ;


  •  Display the last name of all employees who have an a and an e in their last name.
SELECT last_name 
FROM employees 
WHERE last_name LIKE '%a%' 
AND last_name LIKE '%e%' ;


  •  Display the last name, job and salary for all employees whoso job is sales representative or stock clerk and whose salary is not equal to $2,500, $3,500 or $7,000.
SELECT last_name, job_id, salary 
FROM employees 
WHERE job_id IN ('SA_REP', 'ST_CLERK') 
AND salary NOT IN (2500, 3500, 7000);


  •  Display the last name, salary and commission for all employees hose commission amount is 20%.
SELECT last_name, salary, commission_pct 
FROM employees 
WHERE commission_pct = .20 ;

Friday 21 February 2014

Writing Basic SQL SELECT Statements


  • Show the structure of the DEPARTMENTS table. Select all data from the table.
DESC departments;
SELECT * 
FROM departments;


  • Show the structure of the EMPLOYEES table. Write a query to display the last name, job code, hire date and employee number for each employee, with employee number appearing first
DESC employees;
SELECT employee_id, last_name, job_id, hire_date 
FROM employees; 


  • Create a query to display unique job codes from the EMPLOYEES table. 
SELECT DISTINCT job_id
FROM employees;


  • Write a query to display the column headings Emp #, Employee, Job, and Hire Date, respectively, from the EMPLOYEES table. 
SELECT employee_id "Emp #", last_name "Employee", job_id "Job", hire_date "Hire Date" 
FROM employees;
Note: You can also use AS to display the column with other name. For ex: in above query you can also write: SELECT employee_number AS "Emp #" from emp; 


  • Display the last name concatenated with the Job ID, separated by a comma and space, and name the column Employee and Title.
SELECT last_name||', '||job_id "Employee and Title" 
FROM employees;


  • Create a query to display all the data from the EMPLOYEES table. Separate each column by a comma. Name the column THE_OUTPUT. 
SELECT employee_id||','||last_name||','||job_id||','||manager_id||','||hire_date||','||salary||','||commission_pct "THE_OUTPUT" 
FROM employees;

Saturday 15 February 2014

How to Provide Web services to all Clients across the Network

Once you configured the DHCP services (How to Provide DHCP services to all Clients across the Network), then configuring Web services is very easy.
Now if you recall; we configured RIP(Routing Information Protocol) to the Routers to allow communication between clients and also to provide DHCP services across the Network and this is the only thing we need to do with the routers to provide Web services to the clients across the network, no need to provide any helper-address as we provided for the DHCP services.


Configuring the Web services:
Configuring the Web services for the network shown in the picture:

Step 1:
Click the Web server then go to the Config tab and turn off the DHCP services only.

Step 2:
Provide the IP-address from the Desktop tab of the Web server and make sure the IP scheme is different. Here the address is 110.0.0.1


Step 3:
Configure RIP in all the routers in order to make sure the Web services are available to all the clients across the network; which obviously you've done before when you configured the DHCP services.

Step 4:
Now click the DHCP server and under the Config tab click DHCP. Here you will see the pools that you had made when you configured the DHCP server. Now go into every pool one by one and provide the DNS server address; this is the address that you provided to Web server as shown in the picture above. After providing DNS server address your pools would look like this:


Step 5:
Now go into every Laptop and under the Desktop tab click the IP configuration tile and make the DHCP request again to make sure that our client(Laptop) has the DNS server address.


Step 6:
Now click the Web server again and under the Config tab click DNS. There you will see two text boxes, one with a label of name and another is of address. In the name field enter any URL you want for ex:(www.cisco.com) and in the address field enter the same address that you provided the Web server, in our case this is:(110.0.0.1).


Step 7:
Web server is configured. Now it's time to check whether our clients can access the web services or not. Click on any Laptop(Client) and under the Desktop tab click the Web Browser and enter the URL that you provided above. You will see the page is displayed like shown below:




Saturday 8 February 2014

How to Provide DHCP services to all Clients across the Network

The Network is designed and configured in Cisco Packet Tracer version 5.3.0.0088
The Network feeds DHCP services to all the Clients of Network across all Routers.
The Network also has the Web server which feeds Web services to all the Clients across all Routers, but this is not a part of this post. It will be covered later.
In this post my focus is just on configuring DHCP server.


As shown above in the picture the network has four access points that are connected to the Routers and then the Routers are connected to one another, making a loop. While one access point is connected to the switch and we also have a DHCP server which is directly connected to that switch and then the switch is connected to the Router. Our clients(Laptops) are connected(wireless) to their respective access points.

Configuring the Network:

Step 1:
Configure the Routers. You can configure through CLI or trough the user interface, it's your choice. Make sure you have given different IP schemes to all the routers.

Step 2:
Once all routers are configured and all the ports turns green, apply RIP(Routing Information Protocol) to the Routers, to allow data communication and to feed DHCP services to the clients across all routers.

Step 3:
Click the DHCP server and provide IP and subnet mask(IP scheme must be different). Now as shown in the Picture we have five different sub-networks(five access points) so create five pools with Default gateway, Start IP address, Subnet Mask and Max Number of Users.
The default gateway IP is the one which you had given to the port of the router that is connected to the access point. Start IP address will be the network address(for ex: 40.0.0.0). Subnet Mask is the default mask for the IP class that you are using and Max Number of Users means the number of clients to provide IP's, give the value 256.


Step 4:
Now give the helper address to the ports of the Routers that are between path of the clients. The helper-address is the IP address of DHCP server. To provide helper-address, click the router and go to the CLI tab. Go to that port number(for ex: if you have the port number se1/0 type int se1/0). Then type ip helper-address 100.0.0.0(Note: this will be the IP address of your DHCP server). Give that address to all the ports one by one. The figure below will help you understand on what ports you have to give the helper-address, and what do I mean by the path.



Step 5:
Finally we are finished configuring the DHCP server. Now check on the Laptops one by one, you will see that the DHCP request successful message and the laptops are obtaining the IP address from the DHCP server.


Wednesday 5 February 2014

How to Unblock YouTube

There are many ways to unblock YouTube or any other website.

The best way of unblocking YouTube is to go to your browser and type: www.playit.pk and search any video you want to play and download. It also works perfectly on Android. You can also install playit.pk extension to Chrome. Once you installed it you just need to switch it on and you can watch any video you want on YouTube.

The second way is by proxy websites, for example: Go to internet browser and type the address https://12345proxy.com/ and in the page type www.youtube.com it will take you to the YouTube homepage.
Once you able to view the video you can then download it by going to http://en.savefrom.net/. Just paste the video link, select the video quality and download it. No need of any additional video downloading softwares.

Another way of unblocking the websites is to download and install the Google chrome extension named ZenMate. It will secure your connection and unblock any site you want. You just have to switch it on before typing the website address. It has five different locations so that you can set accordingly, depending on the data traffic.

Another way of unblocking YouTube is by installing Hotspot Shield. This will also secure your connection and unblock any website you want. But personally I do not recommend installing hotspot shield because this will degrade the performance of your system and also sometimes it does not work properly.

Hope this is helpful.


Tuesday 4 February 2014

How to Crack the Password of Root and Add Users in Linux


When you start the Linux Operating System, a screen will appear as shown below:




On this screen press e to edit commands before booting.
Hitting e will take you to the following screen. Here you have to make sure that kernel is highlighted, press up and down arrows keys to navigate through the menu and highlight the kernel mode and when the kernel mode is highlighted press e again.



It will take you to the following screen. On this screen just type single as shown below.



This will again take you to the previous screen where you pressed e but this time you have to press b in order to boot.



Now hitting ‘b’ will take you the following screen, on this screen first to crack the root password type passwd then it will ask you a new password, type a new password and then retype it, after this it will show you the message All authentication tokens updated successfully this means you have successfully changed the password of root.



Now we have to add another user and set a password. In order to accomplish this task we need to know the two commands highlighted below. First type the command useradd and after space type the name you want to give the user just like shown below, I have given the name os, this command will create a user you specified. Now to set a password of the user type passwd and name of the user you want to set a password to, just like highlighted below. This will successfully set a password and will show you a message All authentication tokens update successfully. In the end type init 6 to restart the system.



You can see that a user has been created with the name of os. Click this user and provide the password we set to it.





Monday 3 February 2014

How to Recover Data from USB Flash Drive

The size of the USB flash drive indicates that there is some data in it, but why it is not showing the data. Why I'm unable to see my data ? Where is my Data ?
This usually happens when you scan your USB flash drive for viruses.
A single command is the answer for these questions.
No expensive software or tools are required for this data recovery.

To recover these lost files from your USB Flash Drive, you just need to follow these steps:

Step 1: Open the Command Prompt from the Start Menu( If you're using Windows XP or Windows 7). If you're using Windows 8 or 8.1 press WIN + X or right click the Start Menu button, this will open a Power User Menu from where you can open the Command Prompt.

Step 2: Check the drive letter of your USB Flash Drive( for ex: H: I: etc)

Strep 3: Now in the Command Prompt just type the drive letter of your USB Flash drive like this H: and hit ENTER. Now you're into your Flash Drive.

Step 4:  Type this command in the command prompt: attrib -s -h /s /d *.* and hit ENTER, wait for 20-30 seconds and then close the command prompt.

Step 5: Finally check your USB Flash Drive and you can see your DATA IS BACK...!!