Friday, June 22, 2012

Sending mail using gmail in .net

vb.net
Import namespace " System.Net.Mail".And add following coding on button click
Dim m As MailMessage =  New MailMessage() 
  m.To.Add("Email id of receiver")
  m.From = New MailAddress("Add your email it here")
  m.Subject = "Subject line of your mail is kept here"

  String Body = "Add you mail body here" 
   m.Body = Body
 
  mail.IsBodyHtml = True
  Dim smtp As SmtpClient =  New SmtpClient() 
  smtp.Host = "smtp.gmail.com" 
  smtp.Credentials = New System.Net.NetworkCredential
       ("your gmail id","password of gmail")
  smtp.EnableSsl = True
  smtp.Send(mail)

Wednesday, June 20, 2012

Asp.net Error Code BC30456 Method name is not a part of class

I had been working on a project.I create a class and placed that in App_code folder.This class contains a method filldata.Now i complied the project it ran successfully.But again when i compiled it it showed error
filldata is not a method of Search.
I again created object of class and intelligence showed me filldata.But when i compiled it same result was shown.This is nothing but the effect of late copy .When we build website it compiles some files and does really bother about changes in App_code.It may or may not compile class files in App_code.Soit generates compile time Error.
Solution
Just rebuild entire solution again not just Website.It will work.
If you get this error for a website published in IIS then delete all files and folders inside Microsoft.Net\Framework\v4.0.30319\Temporary ASP.NET Files\ based on framework you used for website.

Tuesday, June 12, 2012

Disable right click on your page

<script language=javascript>
var message="Function Not Allowed";
function clickIE4()
{
         if (event.button==2)
        { alert(message); return false; }

}
 function clickNS4(e)
{
           if (document.layers||document.getElementById&&!document.all)
              { 

                     if (e.which==2||e.which==3)
                  { alert(message); return false; 

                   }
               }
}
 if (document.layers)
{ document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4; }
 else
if (document.all&&!document.getElementById){

document.onmousedown=clickIE4; }
 document.oncontextmenu=new Function("alert(message);return false")
</script>

Friday, June 1, 2012

Difference between Delete,Truncate and Drop

Delete
  1. It  is used to delete rows from the table.
  2. Where clause can be used.
  3. Can be rollbacked.
Truncate
  1. Used to delete all rows  from table.
  2. NO where clause can be used.
  3. cannot be rolled back.
Drop
  1. The DROP command removes a table from the database.
  2. Cannot be rolled back.
Note:-
As described above truncate command cannot be rolled back.But there is an exception to that "Truncate can be rolled back when used in a transaction within that particular session but when session is closed there is no guarantee that truncated rows are rolled back".By default all statements are commited .In case of delete all the rows that we delete are stored in log file so they can be recovered.When we use transaction commit operation is performed only after end of transaction.


BEGIN TRAN
TRUNCATE TABLE 
Employee

//table is truncated
SELECT *FROM Employee
//no records will be found
ROLLBACK
SELECT 
*FROM Employee

//original data will be shown