System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage(); myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.gmail.com");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2"); myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "yourid@gmail.com");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "gmailpassword");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
myMail.From = "yourid@gmail.com";
myMail.To = "to@gmail.com";
myMail.Subject = "Subject";
myMail.Body = "body";
if (pAttachmentPath.Trim() != "")
{
myMail.Priority = System.Web.Mail.MailPriority.High;
}
System.Web.Mail.SmtpMail.SmtpServer = "smtp.gmail.com:465"; System.Web.Mail.SmtpMail.Send(myMail);
Monday, April 26, 2010
What is an application domain
Previously "PROCESS" where used as security boundaries. One process has its own virtual memory and does not over lap the other process virtual memory; due to this one process can not crash the other process. So any problem or error in one process does not affect the other process. In .NET they went one step ahead introducing application domains. In application domains multiple applications can run in same process with out influencing each other. If one of the application domains throws error it does not affect the other application domains. To invoke method in a object running in different application domain .NET remoting is used.
Static Constructor
Some important point regarding static constructor from C# Language Specification and C# Programmer's Reference :
1) The static constructor for a class executes before any instance of the class is created.
2) The static constructor for a class executes before any of the static members for the class are referenced.
3) The static constructor for a class executes after the static field initializers (if any) for the class.
4) The static constructor for a class executes at most one time during a single program instantiation
5) A static constructor does not take access modifiers or have parameters.
6) A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
7) A static constructor cannot be called directly.
8) The user has no control on when the static constructor is executed in the program.
9) A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.
1) The static constructor for a class executes before any instance of the class is created.
2) The static constructor for a class executes before any of the static members for the class are referenced.
3) The static constructor for a class executes after the static field initializers (if any) for the class.
4) The static constructor for a class executes at most one time during a single program instantiation
5) A static constructor does not take access modifiers or have parameters.
6) A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
7) A static constructor cannot be called directly.
8) The user has no control on when the static constructor is executed in the program.
9) A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.
Friday, June 26, 2009
Javascript to select all check box from datagrid
Write Following function in
tag.
function CheckAll(dgView)
{
var datagrid = document.getElementById(dgView);
for (var i=0;i < datagrid.rows.length;i++)
{
var e = datagrid.rows[i].cells[0];
for (k=0; k < e.childNodes.length; k++)
{
if ((e.childNodes[k].type=='checkbox'))
{
e.childNodes[k].checked=true;
}
}
}
}
Call above function on button click event by passing datagrid object as a parameter.
tag.
function CheckAll(dgView)
{
var datagrid = document.getElementById(dgView);
for (var i=0;i < datagrid.rows.length;i++)
{
var e = datagrid.rows[i].cells[0];
for (k=0; k < e.childNodes.length; k++)
{
if ((e.childNodes[k].type=='checkbox'))
{
e.childNodes[k].checked=true;
}
}
}
}
Call above function on button click event by passing datagrid object as a parameter.
Javascript to Accept Only Numbers in TextBox
function numbersonly(e, decimal)
{
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
if ((key==null) (key==0) (key==8) (key==9) (key==13) (key==27) )
return true;
else if ((("0123456789").indexOf(keychar) > -1))
return true;
else
return false;
}
{
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
if ((key==null) (key==0) (key==8) (key==9) (key==13) (key==27) )
return true;
else if ((("0123456789").indexOf(keychar) > -1))
return true;
else
return false;
}
Wednesday, May 27, 2009
JavaScript To View Page in Full Screen
Add Following Lines in Script Tag:
url = "FullScreenPage.htm";
var speedX = 7;
var speedY = 5;
var bgColor = "#000000";
var txtColor = "#FF80000";
if (document.all)
{
var wide = window.screen.availWidth;
var high = window.screen.availHeight;
}
function ShowFullScreen()
{
if (document.all)
{
var FScreen = window.open("","BoomWindow","fullscreen");
FScreen.document.write('Loading...');
FScreen.focus();
for (H=1; H {
FScreen.resizeTo(1,H);
}
for (W=1; W {
FScreen.resizeTo(W,H);
}
FScreen.location = url;
}
else
{
window.open(url,"BoomWindow","");
}
}
Call ShowFullScreen() method using javascript event.
url = "FullScreenPage.htm";
var speedX = 7;
var speedY = 5;
var bgColor = "#000000";
var txtColor = "#FF80000";
if (document.all)
{
var wide = window.screen.availWidth;
var high = window.screen.availHeight;
}
function ShowFullScreen()
{
if (document.all)
{
var FScreen = window.open("","BoomWindow","fullscreen");
FScreen.document.write('Loading...');
FScreen.focus();
for (H=1; H
FScreen.resizeTo(1,H);
}
for (W=1; W
FScreen.resizeTo(W,H);
}
FScreen.location = url;
}
else
{
window.open(url,"BoomWindow","");
}
}
Call ShowFullScreen() method using javascript event.
Tuesday, May 19, 2009
ASP.NET Export DataGrid To Excel
Its Very easy to Export DataGrid to Excel. First you populate DataGrid and add following code to export datagrid data to excel. Here datagrid object is 'dgBillDetails'.
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
DataGrid1.VirtualItemCount = 0;
DataGrid1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
DataGrid1.VirtualItemCount = 0;
DataGrid1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
Subscribe to:
Posts (Atom)