Monday, 25 March 2013

Practiced writing Windows Application code using Notepad

Today, I practiced adding new forms in Windows Application, Setting properties to controls and defining event procedure manually by writing the code in Notepad.

When we use Visual Studio we are already provided with Tool Box on the left hand side of the VS. But while creating Windows Application using Notepad we need to write each and every code for placing a control on the form for setting the properties etc like BackColor, Size,Location etc.

Whenever we st a value to any property of a control under property window Visual Studio on behalf of us writes all necessary code by assigning values to the property. This code is available in the Designer.cs file. But when we write code manually the programmer himself need to write all necessary code.

ASP (Active Server Pages)

The name Asp.Net, ASP represents a dll file with the name ASP.DLL and .Net represents .Net framework.

Asp.Net is the technology available in .Net for developing Web Applications. Asp.Net is only technology and not a language hence it requires C#Net or VB.Net language for writing the code.

Web Server 
Web Server is the software i.e responsible for the following :
  • Contain all files related to your website.
  • Provide security for the webpages related to your website.
  • Accept request from the client, in the form of http request.
  • Provide response to the client in the form of http response and provide communication with others servers like database server and email server.

What happens when we double click on an event of a control in the property window ?

When we double click on an event in a property window internally a method gets generated for writing the code and this method  has a special name  Event procedure which is block of code i.e bound with an event of control and gets executed whenever an event occurs.

The code written under event procedure will be executed by the event when it occurs taking the help of a delegate.
Whenever the event occurs it will call the delegate which then execute the event procedure that it bound with the event. Because a delegate is responsible for the  execution of event procedure first the event,delegate and the event procedure should be bound with each other as following :

Syntax:
<control><event> +=new <delegate> (<event proc>)

Example :
 this.Load += new EventHandler(Form 3 Load); 

Events and delegates are predefined under BCL(evens are defined in control classes and delegates are defined under namespace) what is defined here is only an Event procedure.

After defining a Event procedure in Form class Visual Studio links the Event ,delegate and event procedure.

Note : One delegate can be used by multiple events to execute event procedure but all events will not use the same delegates where different events may use different delegates to  execute event procedures.

Sunday, 24 March 2013

Properties And Events

 
 Properties
  • Every control has a properties, events to access the properties of control Visual Studio provides Property window that lists all properties of control. To select press F4 to open it.
  • We can change any property value in the list of property under property window like width, height, font, fore color etc for which we can see the impact immediately after changing the property value.
  • Whenever we set a value to any property of a control under property window Visual Studio on behalf of us writes all the necessary code by assigning values to the property we have modified, we can view that code under Initialize Component method of a class which is called in a constructor of a class.
  • To view code under Initialize Component method ,go to definition code view right click on the method called in constructor and select go to definition this takes us to form.designer.cs and here also we find the same class because it is partial. 
Events
  • This are time period which tells when an action is to be performed i.e when exactly we want to execute a method . Every control has number of events with it where each event occurs at a particular time period.
  • We can access the events of a control also  under property window only to view them in the property window.
  • If we want to write any code that should execute when an event occurs double-click on the desired event corresponding to a control which takes you to the code view and provides a method for writing a code.
  

Thursday, 21 March 2013

Cascading Style Sheet (CSS)

CSS is recommended to design the layout of the page including position of the element, appearance of the element n HTML. CSS can  be specified as inline CSS, Internal CSS and External CSS.
  • Inline CSS : Specifying a CSS style by string style attribute of HTML elements without defining it separately is called as Inline CSS. 
Eg: The following example changes font and color of the heading level h1 using Inline CSS.

<!doctype html>
<html>
<body>
<h1 style= "font-family:arial black; color:blue">
Inforica Pvt lmd
</h1>
</body>
</html>
  • Internal CSS : When CSS styles are defined within the head section then it is called as Internal CSS. While defining CSS in the head section. CSS style will have three main parts- Selector, Property and Value. Selector is used to specify the HTML element for which you are defining the style. property is used to specify the CSS property you want to set and value is used to specify the value for CSS property. Property and its value must be separated by colon and multiple properties must be separated by semicolon.
Eg: The following example defines styles for the elements h1 and h2 as internal CSS.

<!doctype html>
<html>
<head>
<style type = "text/CSS">
<h1>
{
font-family:arial black; color:blue"
}
<h2>
{
font-family:times new roman; color:red"
}
</style>
</head>
<body>
<h1> Inforica Pvt lmt </h1>
<h2> Inforica Pvt lmt </h2>
<h1> Inforica Pvt lmt </h1>
<h1> Inforica Pvt lmt </h1>
</body>
</html>
  • External CSS : Defining the CSS styles in seperate files with extention .CSS is called as external CSS. Advantages of external CSS is that they can be used in any HTM document. To add the reference the External CSS file use style element with src attributes or the link element withen the head section.
Syntax:  <style src = "Filename.css">
             <link rel = "stylesheet" type="text/css">
             href="Filename.css"


Partial Classes

  • They are introduced in C# 2.0 which allows us to define a class on multiple files ie we can physically split a class and put it into different files.

          parts.cs                                                          parts1.cs
         class parts                                                       partial class part{
        {                                                                      method1()
         method1()                                                       method2()
         method2()                                                       }
         method3()                                                      parts2.cs
        method4()                                                       partial class parts{                                           
        }                                                                    method3()
                                                                              method4()
                                                                              }
  • In the above case, the class which is defined in left hand side is redefined using the approach of partial classes wherein in this approach the class is physically separated parts logically it is one single unit ie in both the two cases when we create object of class arts we can access all the methods of the class.
  •  if  we want to define partial class in all the files the class name must be same to tell that this is one class only and moreover we need to use a partial modifier on the class in each and every file.
  • In case of partial class if we want to inherit the class from any other class it will be sufficient if we perform inheritance in one file so that it takes to a complete class
The advantages if defining partial classes are:
  • It allow splitting huge volumes of code into separate files so that managing becomes much easier.
  • Multiple programmers can work on the same class at the same time.

Wednesday, 20 March 2013

HTML(Hypertext Markup Language)

HTML is a presentation language use to present web pages in the browser.HTML is made up of predefined elements and each elements has opening and closing tags and both opening and closing tags must be enclosed in angle brackets.Closing tags must have  the prefix slash(/). HTML is not case sensitive but recommended to write in lower case.

Basic elements of HTML:
  • <html></html>
HTML page must start with opening tag of  <html> and must end with closing tag of </html>
  • <head></head>
This element is use to provide a title for the page, write information related to the page like author of the page. Keywords based on which search engine can find your page and whether or not to refreash the page at specified intervals.
  • <title></title>
This element is used to provide a title for the document which will be displayed within the title bar of the browser. This elements must be inside the heads element.
  • <body></body>
This element is used to specify the actual content to display on the page.
  • Formatting Elements
<h1></h1>
<h2></h2>
<h3></h3> 
<h4></h4>  
<h5></h5> 
<h6></h6> 

This elements are use to create headings from level 1 to the level 6 where level 1 font will be large and from there font size will decrease as the level increase.
  • <p></p>
This element is used to create a paragraph text.
  • <b></b>
Use to make text as bold.
  • <i></i>
Use to make text as italic.