Tuesday, 23 July 2013

Features of vb.net


1.Vb.net is object oriented programmed language
2.vb.net is not a pure object oriented programming language.because it is not compulsory to create a class in vb.net
3.Vb.net is mot strongly types and type safe language .In vb.net when you assign one type of variable to another type then no need to perform the type casting manual and vb.net will perform type casting
implicitly.Hence it is not strongly types and type safe
4.vb.net is not case sensitive
5.In VisualBasic.net no need to terminate the statements with special character like ";"

Monday, 22 July 2013

Asp.net Get dropdownlist selectedIndex using C#.net

As per previous articles we knew how to get the selected value or text from drop down. Now we will know how to get selected Index of dropdownlist. To do this task i have placed one Drop down and button.In the below code first i make selection on drop down then click on the button .It will print the Index value

<title>Get DropdownList selectedIndex in asp.net</title>
</head>
<body>
<form id="dynamicIndex" runat="server">
<div>
<asp:DropDownList ID="ddlIndex" runat="server">
</asp:DropDownList>
<asp:Button id="btnGetSelectedIndex" runat="server" Text="GetselectedIndex"
onclick="btnGetSelectedIndex_Click" />
</div>
Code behind:
public partial class GetDropdownSelectedIndexDB : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
PopulateddlIndexDB();
}
}
protected void btnGetSelectedIndex_Click(object sender, EventArgs e)
{
int DdlselectedIndex=ddlIndex.SelectedIndex;
Response.Write(DdlselectedIndex.ToString());
}
private void PopulateddlIndexDB()
{
try
{
SqlConnection cni = new SqlConnection(ConfigurationManager.ConnectionStrings["DdlIndexConnectionString"].ToString());
cni.Open();
SqlDataAdapter cai = new SqlDataAdapter("select *from ContentType", cni);
DataSet cdi = new DataSet();
cai.Fill(cdi, "Content");
ddlIndex.DataSource = cdi;
ddlIndex.DataTextField = "Content";
ddlIndex.DataBind();
}
catch (SqlException exi)
{
Response.Write(exi.Message.ToString());
}
finally
{
cni.Close();
}
}
}

Sunday, 21 July 2013

Economical JIT compilation in .net

In economical JIT compilation first the ,net application will be complied by the language compiler into MSIL code and will be permanently saved in a file with extension either exe or dll .While executing the application MSIL code will be loaded as it is into memory by attaching a stab to every method and when you call a method for the first time.
                  Then the stub attached to the method will be redirect the control to JIT compiler that will compile only that particular method to CPU native code and execute it.But when you call the same method again the stub attached to the method will be directly control to memory CPU method native code OS readily available

As MSIL code will not be compiled to CPU native code while loading the app loading application will a fast in the someway during executing also as only one method you call is compiled execution will also be fast

Base class Libraries || Framework class Libraries in .net

Class library logically divided into name space and  will contain types similar to header files in 'c' language..Net provides class libraries but unlike header files a class library in .net will contain types.A type can be a class or structure or enumerator or Interface or a delegate. A class library directly will not contain the types,and it is divided into name space and s will contain that type purpose of the name space is to logically group the related types

When ever you want to use a type available in a class library in your application then you must add the reference of the name space that containing type you want to use to your application and for this purpose vb.net provides "imports" statement and C# provides "using" Statement
And they are similar to # include statement in 'C' language

.Net 4.5 framework provides the assemblies name space and types as follows in different versions please click here

Saturday, 20 July 2013

Asp.net Get dropdownlist selected value using C#.net

Hi all,in previous we have discussed on data bind concepts for dropdownlist.So Then we have to know how get the item data when make a selection on drop down.Here in this example i have used one Asp button and dropdownlist. There are two methods to get the selected value.There is a direct method to get value which is "selected Value"  and the other is Text of selected Index.Please comment if it is helpful
<html>
<head runat="server">
<title>Get DropdownList selectedValue in asp.net</title>
</head>
<body>
<form id="dynamic" runat="server">
<div>
<asp:DropDownList ID="ddlType" runat="server">
</asp:DropDownList>
<asp:Button id="btnGetSelectedvalue" runat="server" Text="Get selected Item value"
onclick="btnGetSelectedvalue_Click" />
</div>
</form>
</body>
</html>

Code behind:
public partial class GetDropdownSelectedvalueDB : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
//PopulateDropdownlist
PopulateddlTypefromDataBase();
}
}
protected void btnGetSelectedvalue_Click(object sender, EventArgs e)
{
//selected value using Text method
string DdlselectedText=ddlType.SelectedIndex.Text;
//Get item using selected value
string Ddlvalue=ddlType.SelectedValue.ToString();
Response.Write(DdlselectedText +"or"+Ddlvalue);
}

private void PopulateddlTypefromDataBase()
{
try
{
SqlConnection cnd = new SqlConnection(ConfigurationManager.ConnectionStrings["DdlConnectionString"].ToString());
cnd.Open();
SqlDataAdapter cad = new SqlDataAdapter("select *from Content", cnd);
DataSet cds = new DataSet();
cad.Fill(cds, "Content");
ddlType.DataSource = cds;
ddlType.DataTextField = "Content_Type";
ddlType.DataBind();
}

catch (SqlException exd)
{
Response.Write(exd.Message.ToString());
}

finally
{
cnd.Close();
}
}
}

Standard JIT Compilation .net

Basically JIT compilation in .net is of 3 types standard JIT compilation,Economical or Ecno JIT compilation and pre-jit compilation.

Standard JIT compilation:-
.Net application-->Language compiler-->MSIL codse-->JIT compiler

In standard JustTimeCompiler first the .net application will be compiled by the language compiler into MSIL(Microsoft Intermediate language) code and will be permanently saved in a file with extension either dll or exe.When you execute the applications,then MSIL code vb compiled by the JIT compiler to CPU ntive code and then application is executed
The CPU native code obtained by compiling MSIL code will not be permanently save and Hence every time you run the application entire MSILbcode of your application must re compiled to CPU native code which will take time.hence the drawback of standard JIT compilation is loading appellation in to memory will be slow

Common Language Runtime in .net

CLR is the run time environment in which .net application are executed CLR forms as a layer on top of as providing it services between .net application of OS.It internally contains other components.


Class Loader:Class loader is responsible for verify the class libraries refered the .net application and load all those class libraries into memory to make them available for .net application.
it is not responsible for loading .net application into memory

Code managers:In .net the code manager is responsible for loading .net application code into memory and managing until the .net application was closed..Net application code is classified into
1.managed code
2.un managed Code

Garbage Collector:
This is responsible for memory management for the .net application.when u create variables and objects in the program then allocates memory for them and de-allocating memory when their lifetime is expired


Security Manager:in .net you can provide the security either by using role based security or code access security.When you provide security by using either of this then verifying the security and executing the security related code is the
responsibility of security manager.Role based security provides the security based on the roles available in OS

Exception Manager:Is response for verifying whether there is any possibility for exception ,raise the exception.If there is possibility,verify whether exception handling code is provided and executing is providing and otherwise terminate the program abnormal

Thread Manager:Executing multiple tasks at a time is called as multitasking.To implement multi tasking u need to create threads with in the application.When you create a thread with in .net application for implementing multitasking executing those threads is the responsibility of thread manager

Just In time compiler:
Every .net language provides its own compiler that compiles the application according to the syntax of that language.But all the compiles of .net language will compile the application to MSIL or CIL code.MSIL is a new low level language created by ms.Advantage of MSIL is it is CPU platform independent.But MSIL code is not understandable by the processor.The JIT compiler in CLR is responsible for compiling  MSIL code to CPU native code understandable by the processor.CLR contains multiple JIT compiles one for each CPU platform