byte[] data = FromHex ( "4D657373616765204C696E652032" );
s = Encoding.ASCII.GetString ( data );
public static byte[] FromHex ( string hex )
{
byte[] raw = new byte[hex.Length / 2];
for (int i = 0; i < raw.Length; i++)
{ raw[i] = Convert.ToByte ( hex.Substring ( i * 2, 2 ), 16 ); }
return raw;
}
Monday, August 24, 2009
Friday, May 15, 2009
Use explicit casting instead of DataBinder.Eval to Improve data binding perfomance
The DataBinder.Eval method uses .NET reflection to evaluate the arguments that are passed in and to return the results. Consider limiting the use of DataBinder.Eval during data binding operations in order to improve ASP.NET page performance.
Consider the following ItemTemplate element within a Repeater control using DataBinder.Eval:
<%# DataBinder .Eval(Container.DataItem, "field1") %>
<%# DataBinder .Eval(Container.DataItem, "field2") %>
Using explicit casting offers better performance by avoiding the cost of .NET reflection. Cast the Container.DataItem as a DataRowView:
<%# ((DataRowView)Container.DataItem)["field1"] %>
<%# ((DataRowView)Container.DataItem)["field2"] %>
Consider the following ItemTemplate element within a Repeater control using DataBinder.Eval:
<%# DataBinder .Eval(Container.DataItem, "field1") %>
<%# DataBinder .Eval(Container.DataItem, "field2") %>
Using explicit casting offers better performance by avoiding the cost of .NET reflection. Cast the Container.DataItem as a DataRowView:
<%# ((DataRowView)Container.DataItem)["field1"] %>
<%# ((DataRowView)Container.DataItem)["field2"] %>
Labels:
Data binding,
Gridview,
Runtime data binding
Monday, December 1, 2008
Win32_OperatingSystem-find computer last bootup time
Hi Firends yesterday i have play with Win32_Operating System class and i have found out using this task i can intract with my computer operating system.. I had dig into that and for sample here i am going to write code to find out your computer last bootup time
VB.NET Code
Public Sub Lastbootuptime()
Dim strComputer As String = "." ' Local computer
Dim objWMIDateTime As Object = CreateObject("WbemScripting.SWbemDateTime")
Dim objWMI As Object = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim colOS As Object = objWMI.InstancesOf("Win32_OperatingSystem")
For Each objOS In colOS
objWMIDateTime.Value = objOS.LastBootUpTime
MessageBox.Show("Last Boot Up Time: " & objWMIDateTime.GetVarDate)
Next
End Sub
Abhishek Hingu at:
http://www.indianic.com/
VB.NET Code
Public Sub Lastbootuptime()
Dim strComputer As String = "." ' Local computer
Dim objWMIDateTime As Object = CreateObject("WbemScripting.SWbemDateTime")
Dim objWMI As Object = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim colOS As Object = objWMI.InstancesOf("Win32_OperatingSystem")
For Each objOS In colOS
objWMIDateTime.Value = objOS.LastBootUpTime
MessageBox.Show("Last Boot Up Time: " & objWMIDateTime.GetVarDate)
Next
End Sub
Abhishek Hingu at:
http://www.indianic.com/
Wednesday, September 3, 2008
Generate Counter Image runtime
Tuesday, September 2, 2008
Validate String max length using Reguler Expression in C#
class Program
{
static void Main(string[] args)
{
if (Regex.IsMatch("[Input String]","^.{4,20}$" ))
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
Console.ReadLine();
}
}
{
static void Main(string[] args)
{
if (Regex.IsMatch("[Input String]","^.{4,20}$" ))
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
Console.ReadLine();
}
}
Wednesday, May 21, 2008
Universal Contdown timer + javascript
//Javascript to create Universal Countdown timer
function GetCount(){
dateFuture = new Date(document.getElementById('servertime').value); // Get server datetime to find time difference between local time and server time as per GMT
var d=new Date();
var localTime = d.getTime();
var localOffset = d.getTimezoneOffset() * 60000;
var utc = localTime + localOffset;
var offset = document.getElementById('offset').value;
var london = utc + (3600000*offset);
dateNow = new Date(london); //grab current date
amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates
delete dateNow;
// time is already past
if(amount < 0){
document.getElementById('countbox').innerHTML="Now!";
}
// date is still good
else{
days=0;hours=0;mins=0;secs=0;out="";
amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
days=Math.floor(amount/86400);//days
amount=amount%86400;
hours=Math.floor(amount/3600);//hours
amount=amount%3600;
mins=Math.floor(amount/60);//minutes
amount=amount%60;
secs=Math.floor(amount);//seconds
if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}
if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+", ";}
out += secs +" seconds";
document.getElementById('countbox').innerHTML=out;
setTimeout("GetCount()", 1000);
}
}
//
//
//
function GetCount(){
dateFuture = new Date(document.getElementById('servertime').value); // Get server datetime to find time difference between local time and server time as per GMT
var d=new Date();
var localTime = d.getTime();
var localOffset = d.getTimezoneOffset() * 60000;
var utc = localTime + localOffset;
var offset = document.getElementById('offset').value;
var london = utc + (3600000*offset);
dateNow = new Date(london); //grab current date
amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates
delete dateNow;
// time is already past
if(amount < 0){
document.getElementById('countbox').innerHTML="Now!";
}
// date is still good
else{
days=0;hours=0;mins=0;secs=0;out="";
amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
days=Math.floor(amount/86400);//days
amount=amount%86400;
hours=Math.floor(amount/3600);//hours
amount=amount%3600;
mins=Math.floor(amount/60);//minutes
amount=amount%60;
secs=Math.floor(amount);//seconds
if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}
if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+", ";}
out += secs +" seconds";
document.getElementById('countbox').innerHTML=out;
setTimeout("GetCount()", 1000);
}
}
//
//
//
Subscribe to:
Posts (Atom)