Features of .NET Framework in c#

NET framework provides a user friendly environment for developers to develop, run and deploy the following applications.
NET framework provides a consistent programming languauges to perform several tasks like connecting and retrieving databases, and reading from and writing files.

.NET framework class Library:

The .NET framework class library contains predefined classes which are useful for developers to develop code in applications. Microsoft has created these classes to develop the various applications. This library contains several namespaces and assemblies also.

Common Language Runtime (CLR):

The CLR creates the interoperability between different .NET languages, such as C#, visual basic, by providing common environment for the execution of code written any of these languages.
Every language in .NET has its own compiler, after compiling their codes in their compilers, MSIL code will be generated. This MSIL code is known as intermediate code. This intermediate code is common for all languages in .NET framework. So, CLR provides environment to execute intermediate code.
CLR Responsibilities:         
  • Garbage collection: CLR automatically clean up resources during the execution of the programs.
  • Jit compilation: CLR loads MSIL codes on jit-compilers for execute the code.
  • Code Access Security: in this, CLR provides security objects to access code during execution.
  • Automatic memory management: it has built in functions for allocate or de-allocate the memory of .NET objects.
  • Code verification: It is type safety and prevents code from illegal operations.

Common Type System (CTS):

Common type system provides support for multiple languages because it contains a type system that is common for all languages.CTS provides common data type system for all .net languages. It provides common type system that will use in MSIL code.
For example,
In C#, we have data type “int”.
In VB, we have data type for integer values “integer”.
But CTS uses the data type “system.int32” as a common data type for integer values. This data type is used for ‘int’ and ‘integer’ in MSIL code.

Common Language Specification (CLS):

Common language Specification is a set of rules, which provides interoperability between two .net languages.
CLS is a subset of CTS.
CTS provides rules to design application programming interfaces (API) which are used by all .net languages.

Read More

Bind images in DataList from folder in ASP.Net using C#

I will explain how to save images into folder and how we can bind that images
to datalist using asp.net. It's very easy to store images in folder and binding
that images to datalist. This topic shows how to integrate BinaryImage control into  a DataList control to display images stored as binary images, in data binding scenarios. 

Step 1:

CREATE TABLE [products]
            [ID] [numeric](18, 0) NOT NULL,
            [ProductName] [nvarchar](50) NULL,     
            [Category] [varchar](50) NULL,
            [Price] [int] NULL,
            [Image] [varchar](50) NULL,

Step 2:

SELECT  [ProductName], [Image], [Price],[Category] from products

ProductName           Image                                      Price              Category
LG                          ~\images\lg\lg.jpg                  10000             LG
Nexus 5                ~\images\lg\nexus.jpg           25000              LG
Optimus              ~\images\lg\optim.jpg          30000              LG
Flex                       ~\images\lg\fl.jpg                   20000              LG
GW-620                ~\images\lg\gw 620.jpg         8000                LG
Verizon               ~\images\lg\ver.jpg                12000              LG

SELECT [ProductName], [Image], [Price] FROM [products] WHERE ([Category]='LG')

ProductName                   Image                              Price
LG                                ~\images\lg\lg.jpg           10000
Nexus 5                    ~\images\lg\nexus.jpg       25000
Optimus                  ~\images\lg\optim.jpg      30000
Flex                               ~\images\lg\fl.jpg           20000
GW-620                      ~\images\lg\gw 620.jpg   8000
Verizon                         ~\images\lg\ver.jpg      12000

Under Div section you have to place this code

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <form id="form1" runat="server">
<div class="center_content">
            <div class="center_title_bar">My Product</div>
    <br /><br />  
    <br />
     <asp:DataList ID="DataList5" runat="server" CellPadding="6" CellSpacing="6"
         DataSourceID="SqlDataSource5" RepeatColumns="3" Width="550px">
        <div class="center_prod_box">
                 <table class="prod_box">     
                        <td class="product_title">
                            <asp:HyperLink  ID = "HyperLink1" runat="server" Text='<%# Eval("ProductName") %>' Font-Underline="False" NavigateUrl='<%#"product details.aspx?ProductName="+Eval("ProductName") %>'></asp:HyperLink>
                        <td class="product_img">
                            <asp:ImageButton ID="ImageButton1" runat="server" Height="90px" ImageUrl ='<%# Eval("Image") %>' ImageAlign = "AbsMiddle" PostBackUrl='<%#"product details.aspx?ProductName="+Eval("ProductName") %>'/>                                                 
                    <td class="prod_price">
                        <asp:Label ID="Label1" runat="server" Text = '<%# Eval("Price") %>' ></asp:Label>
     <br />
     <asp:SqlDataSource ID="SqlDataSource5" runat="server"
         ConnectionString="<%$ ConnectionStrings:shauryaConnectionString %>"
         SelectCommand="SELECT [ProductName], [Image], [Price] FROM [products] WHERE ([Category]='LG')">

Note:In above Source code I m using my own css for designing,may be U.I. will look like different in your case.

Read More

How to check username and password from database

In this tutorial I am going to tell you  how to validate a user's credentials match or not and how to retrieve a user's password and email address from a database.

ALTER procedure [dbo].[PasswordRecovery]
(@username nvarchar(30),
@email nvarchar(30),
@password nvarchar(50) output,
@msg nvarchar(30) output)
  if exists(select *from Emp_login where user_id=@username and email_id=@email)
  select @password=password from Emp_login where user_id=@username and email_id=@email
  set @msg='yes'
  set @msg='Credential dose not match. Retry!'

Read More