Check isinteger in c#
string x="2";
bool f = int.TryParse(x,out newinteger
Thursday, October 18, 2007
integer validation
Function to Test for Integers both Positive & Negative
public bool IsInteger(String strNumber)
{
Regex objNotIntPattern = new Regex("[^0-9-]");
Regex objIntPattern = new Regex("^-[0-9]+$^[0-9]+$");
return !objNotIntPattern.IsMatch(strNumber) && objIntPattern.IsMatch(strNumber);
);
public bool IsInteger(String strNumber)
{
Regex objNotIntPattern = new Regex("[^0-9-]");
Regex objIntPattern = new Regex("^-[0-9]+$^[0-9]+$");
return !objNotIntPattern.IsMatch(strNumber) && objIntPattern.IsMatch(strNumber);
);
Printing a HTMLtag using javascript
//Following example will print content inside div named dividentityCard
function ClickToPrint()
{
docPrint=window.open("","Print",print_setting);
docPrint.document.open();
docPrint.document.write('');
docPrint.document.write('');
docPrint.document.write('
');
docPrint.document.close();
docPrint.focus();
}
function ClickToPrint()
{
docPrint=window.open("","Print",print_setting);
docPrint.document.open();
docPrint.document.write('');
docPrint.document.write('
docPrint.document.write('
docPrint.document.writedocument.getElementById "divIdentyCard").innerHTML); docPrint.document.write(' |
docPrint.document.close();
docPrint.focus();
}
Wednesday, October 17, 2007
Javascript Integer validation
//Javascript----------
function IsInteger(e)
{
var KeyChar = e.keyCode;
// Enter
if(KeyChar != 13)
if(KeyChar > 47 && KeyChar <=58)
return true;
else
return false;
else
return true;
}
//Server side Code
textbox1.Attributes.Add("onKeypress","javascript: return IsInteger(event);");
function IsInteger(e)
{
var KeyChar = e.keyCode;
// Enter
if(KeyChar != 13)
if(KeyChar > 47 && KeyChar <=58)
return true;
else
return false;
else
return true;
}
//Server side Code
textbox1.Attributes.Add("onKeypress","javascript: return IsInteger(event);");
Thursday, October 4, 2007
Accessing Control from RadGrid CommandItem
for (int TableLoop = 0; TableLoop <>
if (rgList.MasterTableView.Controls[TableLoop].ToString().Equals("Telerik.WebControls.GridTable"))
{
Table GTable = (Table)rgList.MasterTableView.Controls[TableLoop];
for (int HeadLoop = 0; HeadLoop <>
if (GTable.Controls[HeadLoop].ToString().Equals("Telerik.WebControls.GridTHead"))
{
GridTHead GHead = (GridTHead)GTable.Controls[HeadLoop];
for (int ItemLoop = 0; ItemLoop <>
if (GHead.Controls[ItemLoop].ToString().Equals("Telerik.WebControls.GridCommandItem"))
{
GridCommandItem GItem = (GridCommandItem)GHead.Controls[ItemLoop];
RadComboBox rcmb = (RadComboBox)GItem.FindControl("rddlCopyToEvent");
DestEventID = Convert.ToInt32( rcmb.SelectedValue);
DestEvent = rcmb.SelectedItem.Text.ToString();
}
}
}
if (rgList.MasterTableView.Controls[TableLoop].ToString().Equals("Telerik.WebControls.GridTable"))
{
Table GTable = (Table)rgList.MasterTableView.Controls[TableLoop];
for (int HeadLoop = 0; HeadLoop <>
if (GTable.Controls[HeadLoop].ToString().Equals("Telerik.WebControls.GridTHead"))
{
GridTHead GHead = (GridTHead)GTable.Controls[HeadLoop];
for (int ItemLoop = 0; ItemLoop <>
if (GHead.Controls[ItemLoop].ToString().Equals("Telerik.WebControls.GridCommandItem"))
{
GridCommandItem GItem = (GridCommandItem)GHead.Controls[ItemLoop];
RadComboBox rcmb = (RadComboBox)GItem.FindControl("rddlCopyToEvent");
DestEventID = Convert.ToInt32( rcmb.SelectedValue);
DestEvent = rcmb.SelectedItem.Text.ToString();
}
}
}
Subscribe to:
Posts (Atom)