Tuesday, October 16, 2007

Master pages and child pages -Page Excecution.

Lots of people are in confusion whether the master pages are loaded first or content page(child page is loaded first.I want to make it more clear.

Following is page execution structure of the master page and child pages.

First the controls of the master page will instantiated and then control of the child page is instantiated.

Then the first the page_load event of the child page is executed and then page_load of event is executed.
Share:
Monday, October 15, 2007

What is the diffrence between abstract(must inherit) class and inteface

Following are the main difference between abstract class and interface.

1. Abstract class can contain abstract method while interface does not.
2. Abstract class can contain method body while interface does not.
3. Methods in abstract class can contain any valid access specifier while in interface public access specifier is only allowed.
4. Abstract class can contain methods with body while interface can contain only method signature.

For VB.NET abtract class is must inherit class.
Share:

Overriding static member in child class with C#.NET,VB.NET

Static member are accessible without creating the objects of the class so you don't need to create a object for that class.

Micorosft CLR does not permit the static methods to be override in child class. But off course you can hide the static method of parent method with new keyword in child class. Here is the example of that.


public class A
{
public static virtual void Test()
{
}
}
public class B : A
{
public new override static void Test()
{
}
}
Share:

What is diffrence between string and String in C#.net

There is no diffrence between string and String. string is a alias created by microsoft for System.string.

There are some other datatypes for which microsoft has created the alias.

These are the aliases defined:

string->System.String

sbyte->System.SByte

byte->System.Byte

short->System.Int16

ushort->System.UInt16

int->System.Int32

uint->System.UInt32

long->System.Int64

ulong->System.UInt64

char->System.Char

float->System.Single

double->System.Double

bool->System.Boolean

decimal->System.Decimal
Share:
Tuesday, October 9, 2007

How to insert a item in databound dropdownlist at nth position

Hello guys,

Sorry for not posting anything for long time. Actually i was busy about changing my job.

We have use the dropdownlist with millians of time some developer still does not know that how to insert the listitem at particular level.

Suppose your dropdownlist is having 5 items and it isbound with some datasource and you want to insert "--Select---" on the top of the order. You can do it easily with following code.

DropDownList1.Items.Insert(0, new ListItem("--Select---", "0"));

So "--Select--" will be added at the top of the dropdownlist box. You can add it at any index as you want via specifing index as first argument.

If you are using the asp.net 2.0 then it is having one property
AppendDataBoundItems set it to true and write directly a new list item in html code. It will work.

Happy Programing...


Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews