Sunday, November 30, 2008

Paging in DataGrid

Go to Property Builder - > Paging - > Check Allow Paging and set properties according to your choice.

protected void DataGrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
DataGrid.CurrentPageIndex = e.NewPageIndex;
//Rebind your grid here
DataGrid.DataSource=DataSource;
DataGrid.DataBind();
}

Monday, November 24, 2008

Javascript to open popup window

< script type=" text/javascript " >

var w = screen.availWidth; //For Screen Width
var h = screen.availHeight; //For Screen Height
var Width = (w-100); //
var Height = (h-100);
var left = (w-Width)/2;
var top = (h-Height)/2;

window.open(Path, 'NameOfWindow', 'width='+ Width +', height='+ Height +',top='+ top +',left='+ left +', menubar=no, resizable=no,scrollbars=yes')


< / script >

Wednesday, November 12, 2008

Boxing and UnBoxing

Converting a value type to reference type is called Boxing. Unboxing is an explicit operation.


Example :

class A
{
static void Main()
{
int i = 1;
object o = i; // boxing
int j = (int) o; // unboxing
}
}

Tuesday, November 11, 2008

PUre object oriented language

PUre object oriented language must support these properties.

1. Encapsulation/Information Hiding
2. Inheritance
3. Polymorphism/Dynamic Binding
4. All pre-defined types are Objects
4. All operations performed by sending messages to Objects
5. All user-defined types are Objects

Saturday, November 8, 2008

Javascript on asp.net page

Suppose you want to call some javascript on click of any asp.net button after executing some asp code , you can register javascript and get executed .


string javaScript = " ( script language=' javascript' ) window.close( ) (/script) "; Page.RegisterStartupScript("myScript", javaScript);

This will close the window where this code will be executed.

Thursday, November 6, 2008

Javascript data types

1.Number
2.String
3.Boolean
4.Function
5.Object
6.Null
7.Undefined

Wednesday, November 5, 2008

isNaN

Return true if the argument is not a number

Tuesday, November 4, 2008

Javascript to check if user input has digit in it.

function HasDigit(txt)
{
strLen = txt.length;

for(i=0 ; i < strLen ; i++ )
{
if( (txt.charAt(i)=="0") || (txt.charAt(i)=="1") || (txt.charAt(i)=="2") || (txt.charAt(i)=="3") ||
(txt.charAt(i)=="4") || (txt.charAt(i)=="5") || (txt.charAt(i)=="6") || (txt.charAt(i)=="7") ||
(txt.charAt(i)=="8") || (txt.charAt(i)=="9"))
{
return true;
}
}
return false;

}