0

What is CLR (Common Language Runtime) in the .NET framework



  • The Common Language Runtime is responsible for executing your application code.
  • In .NET, source code is never compiled directly into the machine code. Instead the compiler converts the code into an intermediate language called MSIL(Microsoft Intermediate Language).
  • MSIL is a low-level, platform independent language.
  • Whenever your application executes, the MSIL code is "just-in-time" compiled into machine code by JIT compiler. 
  • JIT compiler is responsible for converting your MSIL code into machine level language for its execution.
  • So, in reality the .NET framework understands only one langauge and that is MSIL.
  • However you can write applications using different languages such as VB, C#, J# etc.


1

Skype has stopped working error in Windows 7

"I recently had this same problem, where my SKYPE would quit after every 5 seconds with a message that said "Skype has stopped working.Windows will now close the program". 
Here is what I did for it to work again. This worked for me, lets hope it works for you too.

1. Firstly you will need to close your skype. Be sure that it is closed by checking the system tray. If skype's icon is still there, right click it and select quit.
2. Next you will need to select show Hidden files from your folder view option.
3. Once that is done press WindowsKey + R: to start the Run Utility
4. Type %appdata%\Skype in it and press enter
5. Delete the shared.xml file.
6. Restart Skype and its done! 
7. A new shared.xml file will be created. And Skype should start working again.
0

Introduction to MVC Architecture

MVC requires .NET framework 3.5 or above. The following describes the architecture of MVC:
MVC stands fro MODEL - VIEW - CONTROLLER.

Controller:
Controller is responsible for recieving request from the web server and identifies the action requirement . Depending on the requirement the controller contacts the corresponding MODEL. The Model will supply the required data, will which be rendered to User Interface using a VIEW.
Controller is responsible for handling request and responding to it.
Inside the controller class several action methods can be implemented.

Model:
Model are responsible for implementing any bussiness logic.
Models are  components responsible for maintaing states. Often this state is maintained in the database.

View:
It is a component responsible for displaying the application's UI.
View can be of any language such as C#, Razor, PHP, JSP etc.
0

Read OR Write a Text file using ASP.Net


The following articles discusses, how one can read and write into a text file using ASP.net Firstly you will need to import  using System.IO; . 











1. Writing to a Text File
 using System;
            using System.IO;

            namespace yasser.howto
            {
                class TextFileWriter
                {
                static void Main(string[] args)
                {
                    // create a writer and open the file
                    TextWriter tw = new StreamWriter(“yrus.txt”);

                     // write a line of text to the file
                    tw.WriteLine("Line to be written in the file!");

                    // close the stream
                    tw.Close();
                 }//end of method
                 }//end ofclass
            }
_________________________________________________________________
2.Reading From a Text File

using System;

using System.IO;
namespace yasser.howto
{
    class TextFileReader
    {
        static void Main(string[] args)
        {
            // create reader & open file
            StreamReader sr = new StreamReader(“yrus.txt”);
            // read a line of text
            Console.WriteLine(sr.ReadLine());
            // close the stream
            sr.Close();
        }
    }
}
-keep coding !

0

Setup FTP server using IIS in Windows 7

Firstly, Please be patient and let all the images load, this will help you understand things better. (click on the image to ENLARGE!)


Start your IIS Manager. The version of IIS Manager that I have used is 6.0. The IIS Manager looks like as shown below.


Now as you can see, I already have 2 website and 1 FTP site configured. Ignore them for now, Lets create a new FTP site.
Right Click as shown in the figure and select Add new FTP option,


Select a name for your FTP Site, and enter the physical path for the content of the FTP site.


Assingn the IP address and the port on which the FTP server will be running, the default port number for a FTP site is 21. You may also enable SSL if needed, and provide the certificate by selecting the certificate from the list.


I have not selected SSL for simplicity,
Then next is where you will define Authorization and Authencation rules. In the example below, I have allowed access to both anonymous as well as basic user. But I have limited their access to READ only by not selecting the Write checkbox.

And TADA .. your FTP is ready!!

You may also change the configuration from the options provided as seen above….
All the options have very user friendly interfaces, and are very easy to configure,
Regards,
YRS
1

Setup FTP server using IIS in Windows 7


Start your IIS Manager. The version of IIS Manager that I have used is 6.0. The IIS Manager looks like as shown below.
Now as you can see, I already have 2 website and 1 FTP site configured. Ignore them for now, Lets create a new FTP site.
Right Click as shown in the figure and select Add new FTP option,
Select a name for your FTP Site, and enter the physical path for the content of the FTP site.
Assingn the IP address and the port on which the FTP server will be running, the default port number for a FTP site is 21. You may also enable SSL if needed, and provide the certificate by selecting the certificate from the list.
I have not selected SSL for simplicity,
Then next is where you will define Authorization and Authencation rules. In the example below, I have allowed access to both anonymous as well as basic user. But I have limited their access to READ only by not selecting the Write checkbox.
And TADA .. your FTP is ready!!
You may also change the configuration from the options provided as seen above….
All the options have very user friendly interfaces, and are very easy to configure,
Regards,
YRS
0

How many column and rows are there in Microsoft Excel 2007

The last cell in EXCEL 2007 is : XFD1048576

0

State Management in ASP.Net

WHAT IS STATE MANAGEMENT, NEED?
Whenever a page is posted to the server, a new instance of the Web Page’s class is created. This means that all the page/control related information will be lost after the post back. To overcome this obstacle, ASP.net provides several options to help preserve this data.

TYPES OF STATE MANAGEMENT

There are 2 types of State Management approach in ASP.net :
 Client – Side State Management 
  1.      View State
  2.      Control State
  3.      Hidden Fields
  4.      Cookies
  5.      Query String


Server – Side State Management 
  1.      Application State
  2.      Session State
  3.      Profile Properties

(1.A) View State
View State is the mechanism that allows state values to be preserved across page postbacks. Because of the stateless nature of the web pages, regular page member variables will not maintain their values after postback.
When we need a page variable to maintain its value across page post backs, we can use ViewState to store that value. Values stored in ViewState will be serialized and sent to the client browser as a value of a hidden form input.  When you view the page source (in your browser) of your page  you will find that it uses View State, which looks something like this:

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/XGSYsks93j580......." /> 

This single hidden field contains all the viewstate values for all the page controls. 
Because viewstate is (by default) sent to the client browser and then returned to the server in the form of a hidden input control on your page, storing a significant amount of data in viewstate can increase your page size and can affect your page performance.
To disable ViewState for a control, you can set the EnableViewState property to false.  When ViewState is disabled for any control, it will also automatically be disabled for all child controls of that control. 

Example:
<asp:Label ID="myLabel" runat="server" EnableViewState="false"></asp:Label>

ViewState["yasser"]  = myValue;
Response.Write(ViewState["yasser"]);

Advantages:
A.      Easy to store and maintain page level data.
B.      Can be set at control level.
C.      Encrypted.
Disadvantages:
A.      Makes a page heavy, if a good amount of data is stored into it.

(1.B) Control State:
  • Control state was introduced in ASP.NET version 2.0.
  • It is similar to View State, but is functionally independent of the View State.
  • A developer can disable view state for a page or for an individual control for performance reasons.
  • However, control state cannot be disabled.
  • Control state is designed for storing a control's essential data (such as a GridView's Page Index) that must be available on postback to enable the control to function even when View State has been disabled. 
  • By default, the ASP.NET page framework stores control state in the page in the same hidden element in which it stores view state.
Eg: If you have written a custom control which has different tabs, where each tab is showing different information. Now in order for that control to work as expected, the control needs to know which tab was selected between round trips to the server. The ViewState property can be used for this purpose, but ViewState can be turned off at a page level by the developers, effectively breaking your control. To solve this, CONTROL STATE can be used.
The ControlState property allows you to persist property information that is specific to a control and it cannot be turned off like the ViewState property.

(1.C) Hidden Fields
  • ASP.NET allows you to store information in a HiddenField control, which renders as a standard HTML hidden field.
  • A hidden field does not render visibly in the browser, but you can set its properties just as you can with a standard control. 
  • When a page is submitted to the server, the content of a hidden field is sent in the HTTP form collection along with the values of other controls.
  • A hidden field acts as a repository for any page-specific information that you want to store directly in the page.
Advantages: Simple to implement.
Disadvantages: It is easy for a malicious user to see and modify the contents of a hidden field.
eg : <input type="hidden" name="__Yasser" id="__Yasser" value=""/>


(1.D) Cookies

  • A cookie is a small amount of data that is stored either in a text file on the client file system or in-memory in the client browser session.
  • It contains site-specific information that the server sends to the client along with the page output.
  • Cookies can be temporary (with specific expiration times and dates) or persistent.
  • You can use cookies to store information about a particular client, session, or application. 
  • The cookies are saved on the client device, and when the browser requests a page, the client sends the information in the cookie along with the request information. The server can read the cookie and extract its value. 
  • A typical use is to store a token (perhaps encrypted) indicating that the user has already been authenticated in your application.
  • The browser can only send the data back to the server that originally created the cookie. However, malicious users have ways to access cookies and read their contents. It is recommended that you do not store sensitive information, such as a user name or password, in a cookie. Instead, store a token in the cookie that identifies the user, and then use the token to look up the sensitive information on the server.
  • A cookie can have a maximum size of 4KB.
  • Response.Cookies["id"].Value = "786";
  • Response.Cookies["id"].Expires = DateTime.Now.AddDays(3);

(1.E) Query String

  • This is the most simple and efficient way of maintaining information across page requests.
  • The information you want to maintain will be sent along with the URL to the server. A typical URL with a query string looks like
  • eg: www.yasser-shaikh.com/search.aspx?query=mumbai
  • The URL part which comes after the ? symbol is called a QueryString.
  • QueryString has two parts, a key and a value. In the above example, query is the key and mumbai is its value. 
  • You can send multiple values through querystring, separated by the & symbol. The following code shows sending multiple values to the Home.aspx page.
  • Response.Redirect("Home.aspx?id=786&name=yasser");
  • The following code shows reading the QueryString values using C#
  • string id = Request.QueryString["id"];
  • string name = Request.QueryString["name"];
  • Query string is lightweight and will not consume any server resources. It is very easy to use and it is the most efficient state management technique.
  • You can pass information only as a string.
  • Information that is passed in a query string can be tampered with by a malicious user. Do not rely on query strings to convey important or sensitive data. Additionally, a user can bookmark the URL or send the URL to other users, thereby passing that information along with it.
  • URL length also has some limitations. So you cannot send much information through query string.







(2.A) Application State
(2.B) Session State
(2.C) Profile Properties

0

Me n DALE STYN

Its me with the south african pacemen DALE STYN,
Location:Colaba Causeway
yes!
0

Imperative v/s Declarative Statements

Imperative statements are those statements that are written programmatically, whereas Declarative statements are those statement that are not written programmatically, they are written using scripts, using wizards(mouse click interfaces) and various other means but not programmatically.
0

Object Oriented Programming Concepts

PAGE UNDER CONSTRUCTION

1. What is OOPS ?
Object-oriented programming (OOP) is a programming paradigm using "objects" (data structures consisting of data fields and methods together with their interactions) to design applications and computer programs.

2.What is an Object?

>> An object is an instance of a class.
>> An object can be considered a "thing" that can perform a set of related activities.
>> There are three properties of an object viz.
a. Identity
b. State
c. Behaviour

3.What is a Class?
>> A class is the blueprint from which the individual objects are created. Class is composed of three things: a name, attributes, and operations.

>> A class defines the properties of the object and the methods used to control the object’s behaviour.

4.What is Encapsulation ?
Encapsulation implies that the non-essential details of an object are hidden from the user and an access its provided to its essential details.
>>eg: Computer games also use this feature. The user only needs to know how to play the game, the complex working of the game is hidden from the user.
Encapsulation is the feature that provides security to the data and the methods of a class.

5.What is Abstraction ?
Abstraction is a process of hiding  unwanted details from the user.
Abstraction also means ignoring the non-essential details of an object and concentrating on its essential details.

6.What is Inheritance ?
Inheritance enables you to extend the functionality of an existing class.
When you create a class that inherits another existing class, it will inherit the attributes and behavior of that class, plus it can also have new attributes and behavior that are specific to that class.
>>Advantage: Code-Resuability which result in saving time and energy.

7.What is Polymorphism ?
Polymorphism - Poly stands for many and morph means form. So any thing that exists in more than one form is known as polymorph.
In oops, polymorphism means assigning a  different meaning to an entity in different context.

8.Types of Inheritance ?


There are 5 types of inheritance,
a. Single Inheritence >> One Super Class and One Sub class.
b. Multiple Inheritance >> More than One Super Class and One Sub class
c. Multi Level Inheritance >> A Class which is a Sub class of One class,      becomes a Super class for another class.
d. Hierarchical Inheritance >> One Super Class and many Sub classes
e. Hybrid Inheritance >> Multiple and Multi level combined.

9.Types of Polymorphism ? 


>> There are two types of polymorphism 
1. Run Time Polymorphism
2. Compile time Polymorphism 
>> To achive the Compile Time polymorphism there two ways
1. Function Overloading
2. Operator Overloading
>> To achive the Runtime Polymorphism we need to use 
1. Virtual functions

Q. What is a Virtual Function ?

>> Virtual functions are normal member functions of a class, which can be over-ridden in the derived classes. The whole functionality can be replaced in the over-riding function.
>> In C#, the virtual functions will be declared with a keyword 'virtual' and the over-riding functions will be declared with 'override' key word.


Class Base_Class
{
public virtual void MyMethod(){}
}


Class Derived_Class:Base_Class
{
public override void MyMethod(){}
}


10. What is Serialization and De-Serialization?

Serialization is the process of converting an object into a series of bytes for transmitting or storing purpose. Deserialization is a process, where these same bytes are converted back into objects.

11.What is an Abstract Class ?
>> Abstract class is a class which cannot be instantiated but it is inherited by derived classes. This class contains abstract as well as non-abstract methods and members.

>> Any concrete class (i.e not abstract) inheriting an abstract class MUST implement ALL inherited abstract method.



12. What is an Interface ?
>> Interface is a contract for what a class MUST do, but it does not specify the way it should be done.
>> An interface contains only the signatures of methods (only the declaration). A class implementing the interface must implement all the members of the interface (i.e provide the definations for those methods).
>> Interface separates the implementation and defines the structure, and this concept is very useful in cases where you need the implementation to be flexible.
>> Interfaces can inherit other (many) Interfaces.
>> A Class can implement many Interfaces.



13. Abstract class vs. Interface
>> An abstract class can have abstract members as well non abstract members. But in an interface all the members are implicitly abstract and all the members of the interface must be overriden in its derived class.
>> A class can inherit one or more interfaces, but only one abstract class.
>> An abstract class can have 0 abstract method.
>> Abstract class can have fields (such as int, string etc) , whereas Interface cannot.

14. Garbage Collection (Finalize, Dispose Methods)

15. What are Wrapper Classes.

16. What are Threads.

  
0

Call a Javascript function from C#

There are many ways in which you can call a javascript method from your .cs file. The following 2 are best (easiest ;P ) method.

Consider a sample .aspx file as below, where we have a javscript method named - callMe(), our aim in this tutorial is to call this method by using c# code.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Resultmaker.ProjectList.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
<script type="text/javascript">
    function callMe() {
        alert("call successfull");
    }
</script>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>

In your .cs file you may use either of the following, to call your javascript method.

// Method 1
Response.Write("<script language='javascript'>alert('Yasser');</script>");
            
//Method 2: The more preferred approach.
string scrname;
scrname = @"<SCRIPT language='javascript'> callMe();" + "</SCRIPT>";
ClientScript.RegisterStartupScript(this.GetType(), "yasser", scrname.ToString(), false);
        


:)
 

2011 ·Code-Studio by yrus.