Thursday, 28 March 2013

Radio Button and Check Box


This two controls will be used when we want to provide the user with the list of values to choose from.The difference between these two controls is, radio button control is used when only a single value has to be selected from the list whereas check box is used when we want to provide multiple values to choose from list.
As a radio button supports single selection only once we select the second radio button automatically the first one gets deselected. But if we have requirement of using radio button under different places or option we need to group radio buttons by placing them on a separate container like panel, groupbox etc so that one radio button can be selected from each group.

Checked is a property provided by radio buttons and check box control to identify which control has been selected its a Boolean property that returns true if the control is not selected.

Tuesday, 26 March 2013

Creating ASP.Net Web Pages

An ASP.Net web page must have page directive at the page based on which  the web server  IIS identifies that  it is an ASP.Net page and it is also use to specify which language you want to use to write the code for ASP.Net web page.

Page Directive
<% @ page language="cs/vb"%>

An ASP.Net web page can contain HTML element, Java Script, CSS and Server Side code written using C#.Net or Vb.net language.

Server Side Code(for Single statement)
To write server side code using C#.Net or VB.Net language use the following syntax:
  <>%=stmt%>

Server Side Code(for multiple statement)
  <%
      stmt1
      stmt2
      .....
%>

Server side code(for creating reusable functions)
<script language="cs/vb" runat="server">
</script>

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"