Showing posts with label General. Show all posts
Showing posts with label General. Show all posts

Wednesday, 24 July 2013

populate textbox with other textbox value in asp.net using javascript

In this articles i will explain about one more standard web control. This control is used to enter the data or can take data from user i:e Text Box.In asp.net Text box has properties to restrict the Lines of data which is Tex Mode property(Single Line and MultiLine).The following example shows how to populate text box with other text box value using Java Script.
                                           Java Script is client side programming which has an event "onblur" to focus functionality.In java script we can't get control value directly.If you want to get the control value,First we need to get the control id using "getElementById" then we can get the value as result.In the above example i have used two text box controls .When the focus has come to second text box ,it will be filled with first Text Box.
<html>
<head>
<script>
function AppendDataToOtherTextBox()
{
var BName=document.getElementById("BooKName");
var BBN=document.getElementById("BooKName1");
BBN.value=BName.value;
}
</script>
</head>
<body>
Enter Book name: <input type="text" id="BooKName" onblur="AppendDataToOtherTextBox()">
Blur Field: <input type="text" id="BooKName1">
</body>
</html>

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 ";"

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

Friday, 19 July 2013

Common Language specification(CLS) and common type system(CTS) in .net

.Net is collection of multiple languages.CLS provides a set of rules and object oriented programming model to be followed by every .net language.when a language follows these set of rules and object oriented programming model then the language said to be CLS compliant i:e the .net language otherwise the language will not be treated as .net language

Common Type System(CTS):In .net every data type is internally represented as a class or structure and they class or structure of the data type provides the methods you can on that type
For example string data type in .net is internally representing with the name "String" and is string class provides the methods like ToLower() using which u ca convert the string to Lowercase and UpperCase

All these classes and structures related to data types are available in CTS even every .net language is providing its own keywords for the data type,internally all .net languages will use the same classes and structures available in CTS

For examples vb.net provides the keyword Integer for storing integer data and C# provides the keyword Int for storing integer data .Buy internally both vb and c# will use the structure in t32 available in CTS. when a variable is declared integer without CTS it is not possible to declare variables in /net application

UnManaged code in .net

.Code for which there is no MSIL executed after the language compile compilation is not executed by the CLR directly rather the CLR will collect all the required resources and redirectly the code to as for execution which is known as unmanaged code And the code execution process is known as unmanaged code execution
For unmanaged code exe CLR does not provide any features of facilities like common
1. data type system
2. Automatic memory management
3. JIT compilation
4. Exception handling mechanism etc

.net source code(Managed code)-->LC-->MSIL-->CLR(unmanagedcode)-->Nativecode-->Code executed

Thursday, 18 July 2013

Bind data to dropdownlist in Asp.net

The rencent posts have given on populate dropdownlist with different source controls.Now i will showing a process which is not used any data source control or generic control.Here we need to create a connection string to data base in configuration file ,then it will be access to code behind file while require to DB connection.After that we can get the data from table using SqlDataAdapter and fill to connection less data set.Finally it has to be used as data source of dropdownlist
<html>
<head runat="server">
<title>Bind Data To DropdownList in asp.net</title>
</head>
<body>
<form id="dynamic" runat="server">
<div>
<asp:DropDownList ID="ddlcollege" runat="server">
</asp:DropDownList>
</div>
</form>
</body>
</html>
Connection String in Web.Config:
<add name="DbJConnectionString" connectionString="Data Source=jyothim\sqlexpress;Initial Catalog=TestDb;Integrated Security=True"
   providerName="System.Data.SqlClient" />
Code behind:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;

public partial class PopulateDropdownListDB : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
PopulateDropdownDynamicallyfromDataBase();
}
}
private void PopulateDropdownDynamicallyfromDataBase()
{
try
{
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["DBjConnectionString"].ToString());
SqlDataAdapter ad = new SqlDataAdapter("select *from CollegeName", con);
DataSet ds = new DataSet();
ad.Fill(ds, "College");
ddlcollege.DataSource = ds;
ddlcollege.DataTextField = "college_name";
ddlcollege.DataBind();
}
catch (SqlException ex)
{
Response.Write(ex.Message.ToString());
}
}
}

Managed Code in .net

1.The code for which MSIL is generated after the language compiler compilation is directly executed by CLR which is known as Managed Code and the code execution process is known as managed code execution
2 .For managed code execution CLR will provide all the facilities or features of .net like
i)Common data type System
ii)Automatic Memory Management
iii)JIT compilation
iv)Code access Security
v)Exception handling Mechanism etc
3.For manage code execution CLR will contain common set of languages rule i;e common language syntax
4.Every programming language syntax will be converted into their common syntax at the time of compilation

Difference between dot net and vs.net

.Net framework is code form .net and it is used to execute .net programs or application.With frame work we can't execute any .net programs.Visual studio .net is just for an editor tool used to build the .net programs or application

.Net Framework
1.Execution environment of .net programs/applications
2.Free software.
3.Occupies a memory of 150mb to 350mb
4.dot net 1.0,2.0,3.0,4.0,4.5 are versions

VisualSTudio.net
1.Desinging/Development environment of .net programs/application
2.It has also free editions
3.Occupies memory of 1.5gb to 3.5GB with out MSDN
4.VS.net2000,2003,2005,2007,2008,2010,2012 are different versions of VS.net

Wednesday, 17 July 2013

Option statements in vb.net

Vb.net provides three types options statements
Option Explicit On/Off:This option is used to specify weather variable declaration is mandatory in vb.net .By default this option was set  to "ON"that indicates you must declare the variable before using it.When this option was set to "OFF" you can use a variable with out declaring it and in this case the type f variable will be object and it can be store any type of value
Option Explicit off
module module1
sub main()
s1="jyothi"
End sub
End module

Option Strict On/Off
This option is used to specify whether type casting is done implicitly by vb.net or user has to perform manual. By default this option was set to "OFF" indicating vb.net will
implicitly perform typecasting and when this was set to "ON" then user must perform the typecasting manual
Option Strict on
Dim s1 As string="test"
Dim n As Integer=int.Parse(s1)

Option Compare Text/Binary:
This option  is used to specify how the strings will be compared.By default this option is set to "binary" that indicates string will be compared with case sensitivity when this option was set "TEXT" string will be compared with out case sensitivity

Option Compare Text
Dim s1 As string="JYOTHI"
Dim s1 As string="Jyothi"
console.WriteLine(s1=s2)

Difference between Read() and ReadLine() in C#.net

ReadLine():It is used to read the values into variables from the keyboard and it is similar to the library function "scanf" in "C' language
var=Console.ReadLine();
1.ReadLine method will return any value enter to the keyboard as a string
2.vb.net will automatically perform type casting when you read the values for variables other then string
Here i will provide MSDN ReadLine link to get the brief explanation on it.

Read():
1.This method is similar to the library function getch() in "c" language .
2 It is used to read the single character and will not be displayed on the screen
3.MSDN Read() Method