Exception LastError;
String ErrMessage;
LastError = Server.GetLastError();
if (LastError != null)
{
ErrMessage = LastError.Message;
}
else
{
ErrMessage = "No Errors";
}
Response.Write("Last Error = " + ErrMessage);
Wednesday, January 27, 2010
Asp.net - How to find last error which occurred?
Monday, January 25, 2010
What is the difference between CONST and READONLY?
A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or in a constructor.
Therefore readonly fields can have different values depending on the constructor used.For eg.
readonly int a;
public class()
{
a=1;
}
public class(string s)
{
a=5;
}
public class(string s, int i)
{
a=i;
}
A const field is a compile-time constant meaning that it is evaluated at compile time, the readonly field can be used for runtime constants which means value gets evaluated during runtime.
Therefore readonly fields can have different values depending on the constructor used.For eg.
readonly int a;
public class()
{
a=1;
}
public class(string s)
{
a=5;
}
public class(string s, int i)
{
a=i;
}
A const field is a compile-time constant meaning that it is evaluated at compile time, the readonly field can be used for runtime constants which means value gets evaluated during runtime.
Monday, January 4, 2010
using directive vs using statement :
Create an instance in a using statement to ensure that Dispose is called on the object when the using statement is exited. A using statement can be exited either when the end of the using statement is reached or if foreg an exception is thrown and control leaves the statement block before the end of the statement.
Using directive has two uses:
Create an alias for a namespace.
Permit the use of types in a namespace such that you do not have to qualify the use of a type in that namespace .
Using directive has two uses:
Create an alias for a namespace.
Permit the use of types in a namespace such that you do not have to qualify the use of a type in that namespace .
Wednesday, September 23, 2009
On button click - how to bring up browsers emailing box using javascript.
INPUT TYPE="button" VALUE="Send Email." onClick = "parent.location= 'mailto:mymailid@gmail.com'"
Show Timer on status bar using Javascript
function showtime ()
{
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " P.M." : " A.M."
window.status = timeValue;
}
Call this function on load of the form.
{
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " P.M." : " A.M."
window.status = timeValue;
}
Call this function on load of the form.
Tuesday, September 22, 2009
Check the browser type using javascript.
if(navigator.appName=="Netscape")
{
alert("Browser is Netscape Navigator.");
}
else if (navigator.appName == "Microsoft Internet Explorer")
{
alert("Browser is Microsoft Internet Explorer.");
}
else
{
alert("Neither Netscape Navigator nor Internet Explorer.");
}
{
alert("Browser is Netscape Navigator.");
}
else if (navigator.appName == "Microsoft Internet Explorer")
{
alert("Browser is Microsoft Internet Explorer.");
}
else
{
alert("Neither Netscape Navigator nor Internet Explorer.");
}
Thursday, September 10, 2009
Year is a leap year or not.
Suppose you want to know if 2009 is a leapyear or not.
Use:
bool Result = DateTime.IsLeapYear(2009);
Use:
bool Result = DateTime.IsLeapYear(2009);
Subscribe to:
Posts (Atom)