Monday, August 25, 2008

C Sharp Basic Concept - framework tutorials

C# Language

C# does not allow multiple inheritances.
C# does not allow use of pointer.
Provide garbage memory collection at runtime.
C# comes with new and exciting features like reflection, marshalling, threads, remoting, attributes, streams and data Access with ADO.NET and more

The .NET Architecture and .NET Framework

The .Net Architecture and the .Net framework are different important terms and concept.

CLR (The Common Language Runtime)

The most important concept of the .Net Framework is the existence and functionality of Common Language Runtime (CLR).
It is also called .Net Runtime.
It is a framework layer that resides above the Operation system and handles all the execution of .Net application.

.Net programs are don’t diretly communicate with operating system bit go through the Common Language Runtime.

MSIL (Microsoft Intermediate Language)

When we compile our .net program using any .net compliant language such as C#, C++.NET VB.Net our source code does not get converted in to the executable binary code, but to an intermediate code known as MSIL which convert our program into executable binary code to CLR.

MSIL is operating system and hardware independent code.

Cross language relationships are possible as the MSIL code is similar for each .Net language.

Just in Time Complier (JIT)

When our MSIL compiled code needs to be executed, the CLR invokes the JIT compiler, which compile the IL code to native executable such as .exe or .dll that is designed for the specific machine and OS.

E.g. when a function is called, the IL of the functions body is converted to native code just in time. So, the part code is not used by that particular run is never converted to native code. if some IL code is converted to native code, then the next time it’s needed the CLR reuses the same copy without recompiling.

The Framework Class Library (FCL)

The .NET Framework provides a huge framework or Class library for common use (FCL). FCL contains thousands of classes to provide to Windows API and common functionalities like String Manipulation, Common Data Structure, IO, Streams, Threads, Security, and Web Programming etc.

The Common Language Specification (CLS)

CLS is simply called .Net compliant Language. All the .Net compliant language can make use of CLR and FCL. Microsoft has release a small set of specification that each language should meet a qualify as a .Net Compliant Language. As IL is a very rich language, its is not necessary for an language to implement all the IL functionality, rather, it merely needs to meet a small subset of CLS to qualify as a .Net Compliant language.

The Common Type Systems (CTS)

Like CLS, CTS is also a set of standards. CTS define the basics data types that IL understands. Each .Net compliant language should map its data types to these standard data types. For example CTS defines a type Int32, an integer data type of 32 bit94 byte) which is mapped by C# through int and VB.Net through Integer data types.

Garbage Collection (GC)

CLR also contains the garbage Collector (GC), which run in low-priority thread and checks for un-referenced dynamically allocated memory space.

The .Net Framework

The .Net framework is the combination of layers of CLR, FCL Data and XML Classes and our Windows, Web applications and Web services.

Download MS-Word file C# Basic Concepts

Avoid dropdownlist multiple selection problem

How to avoid Multiple selection not allowed in DropDownList problem

i get one error when i compile my program, the error message is multiple section of DropDownList is not allowed, i debug my program but i didn't get any multiple section on in DropDownList. i use one update panel for AJAX operations. i think that error come from some unwanted selection of update panel. finally i remove that error by using

DropDownList1.ClearSelection(); then is add

it works fine cant get any errors after that.
to avoid this use DropDownList1.ClearSelection(); then add selection of DropDownList.

Wednesday, August 13, 2008

How to add Dynamic TextBox in ASP.NET C# - code samples

How to add TextBox Dynamically in ASP.NET C#
we can dynamically add controls in Pages. Hera i am explain how to add textbox control in our .aspx page. use PlaceHolder control for Holding the dynamically added control. Below am showing the C# code for generating textbox control. if u have any doubt on this article please comment below.

C# Code

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default2 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
/// Function for Generating Dynamic Textbox
/// for creating TextBox Dynamically ,first create a Table then table Row then TableColumn
/// add TextBoxes in TableColumn with ID
/// Add TableColum in TableRow
/// Add TableRow In Table
/// Add that Table in PlaceHolder
public void GenarateTextBox(PlaceHolder PlaceHolder1, int RowCount, int ColCount)
PlaceHolder ph = new PlaceHolder();// PlaceHolder for Hold dynamically createing Text Box
Table objTable = new Table(); //
if (objTable.GetType().ToString().Equals("System.Web.UI.WebControls.Table") && PlaceHolder1.FindControl("objTable") == null)
objTable.ID = "objTable";
objTable.EnableViewState = true;
objTable.BorderWidth = Unit.Pixel(0);
objTable.CellPadding = 3;
objTable.CellSpacing = 0;
objTable.Width = Unit.Percentage(6);
TableCell objtableCell;
for (int j = 1; j <= RowCount; j++) 
{TableRow objTableRow = new TableRow();
for (int i = 1; i <= ColCount; i++)
 {  objtableCell = new TableCell();
    TextBox objTextBox = new TextBox();
     {  objtableCell.HorizontalAlign = HorizontalAlign.Left;
        objtableCell.VerticalAlign = VerticalAlign.Middle;
 objtableCell.Height = Unit.Pixel(10); 
objTextBox.ID = "TextBox" + j + i;
objTextBox.Text = "TextBox" + j + i;
objTextBox.CssClass = "textarea1"; 
objTextBox.Width = Unit.Pixel(100); 
objtableCell = new TableCell(); 
protected void Button1_Click(object sender, EventArgs e) { 
 }  } 

Download Source Code Complete C# ASP.NET source Code