Wednesday, August 6, 2008

ASP.NET How to send email

How to send email using asp.net?
1. Can you tell me a situation where this program can be used?
You have created asp.net application.
In that application, there is a Registration Form.
When a user submits this Registration Form, you want to send a password to his email address.
2. Code:

3. Addl Info:
  • Your server should have DotNet Framework Installed,SMTP Installed.

  • This is a very simple tutorial. If you want to have other facilities such as sending attachments,etc, then please search the Internet.
  • Tuesday, August 5, 2008

    DHTML For Beginners

    You will learn
    1. What is DHTML. 2. If I want to create DHTML web site, then I should know something about html,css and javascript. Is this statement is true or false? 3. Why the word "DYNAMIC" is used in "DHTML"? 4. What do you understand by 'Coronary Artery disease'?
    DHTML stands for?
    Dynamic HyperText Markup Language.
    In what way it is different from Normal HTML?
    If you are able to bring some kind of DYNAMIC EFFECT (animated effect) in your html page, by using CSS AND JAVASCRIPT, then your page can be called as DHTML page.
    Hmmm! Not able to grasp the meaning of DYNAMIC EFFECT? Don't worry. Let us try with some example. Move your mouse over Rani and Preity.
    Move your Mouse over me Move Your mouse over me. Yes, now you agree that this page has some kind of dynamic or animatic or interactive behavior.Is that right? If the web developer has used CSS and JAVASCRIPT to bring this dynamic property to his page, then that page is a DHTML page

    Example 2 : Move your mouse over the three color boxes.

         

    Example 3.When you click the button, there will be an earth quake. (Anyway, there is no need of holding your chair while clicking)


    I can hear your shouting "Aiyaiyo ! It is really Dynamic paa.."

    Is that all I should know about DHTML?

    If you want to act before your fig... as if you know DHTML, then this is more than enough. But if you are a web designer and if you want to implement DHTML, then you have to read more. The best web site I recommend is W3schools. Don't miss this site. It is really really really really really a SUPER SCHOOL for any web developer.

    Ooooops ! DHTML is enough for today. Let us take a diversion and learn what is CORONARY ARTERY DiSEASE.

    1. It is commonly known as Heart Disease.
    2. It is the leading cause of death in USA and other countries.
    3. Cholesterol is deposited in the artery walls as plaque and block the flowing of blood.
    4. So, for the sake of you and your family Browse more about cholesterol than DHTML. Better visithealth central.com
    http://www.healthcentral.com

    Java For Beginners

    What is Java?
    1.It is Object Oriented Programming Language.
    2.It is platform independent.
    3.It has automatic memory management.


    What is Object Oriented Programming?
    It has 5 properties.
    1.Abstraction
    2.Encapsulation
    3.Inheritance
    4.Modularity
    5.Polymorphism


    What are the things you need to run a java program?
    1.JDK software (available in http://java.sun.com/javase/downloads/index_jdk5.jsp)
    2.Set the environmental variables


    How to set the environmental variables
    There are two methods.
    First Method:
    1.Right click on My Computer,and select properties.
    2.Select the Advanced tab.
    3.Click on Environmental variables button on the bottom.
    4.In the System Variables, click on New button.
    5.Set Variable Name : CLASSPATH
    Variable Value :C:\jdk1.5\lib; and click OK. 6.Again click New Button. 7.Set Variable Name : PATH Variable Value :C:\jdk1.5\bin; and click OK.

    Second Method:
    1.Goto command prompt and navigate to the corresponding folder.
    2.set path=c:\jdk1.5\bin;
    3.set classpath=c:\jdk1.5\lib;.;


    How to write a java program?
    1.Open Notepad
    2.Write the program
    3.Save it with .java extension


    Important things to be noted while writing a Java Program
    1.Java is case sensitive.
    2.Be careful with the filenames,it should match with the class names(case).
    3.There should semicolon after every statement.


    General Structure of a Java program
    public class CLASSNAME
    {
     public void METHODNAME(){
        //method body
     }
     public static void main(String args[]){
        //body
     }
    }


    Hello World
    public class HelloWorld{
     public static void main(String args[]){
        System.out.println("Hello World");
     }
    }
    c:\>java HelloWorld
    Hello World


    Command Line Arguments
    public class CmdArgs{   public static void main(String args[]){     System.out.println("The first argument is " + args[0]);   } }
    c:\>java CmdArgs Hello
    Hello

    Usage of If-else
    public class ExIf{   public static void main(String args[]){     if(args[0].equals("args")){       System.out.println("You entered args");     }     else{       System.out.println("You did not enter args");     }   } }
    c:\>java ExIf args
    You entered args

    Usage of For loop
    public class ExFor{   public static void main(String args[]){     for(int i=1;i<=args.length;i++){       System.out.println("The " + i + "th argument is " + args[i-1]);     }   } }
    c:\>java ExFor One Two Three
    The 1th argument is One
    The 2th argument is Two
    The 3th argument is Three

    Usage of while loop
    public class ExWhile{   public static void main(String args[]){     int i=1;     while(i<=args.length){       System.out.println("The " + i + "th argument is " + args[i-1]);       i++;     }   } }
    c:\>java ExWhile One Two Three
    The 1th argument is One
    The 2th argument is Two
    The 3th argument is Three

    Excel Macros


    1. What is a macro?
    If you find yourself doing the same routine task over and over again, you might want to consider creating a macro to complete the task for you. A macro helps you perform routine tasks by automating them.


    2. Not clear with it,here is some more.
    Let us consider a robot to which every instruction has to be given seperately.For example, if you want it to drink water, then you would tell him to get up, walk to cooler, fill the glass, drink it etc.Instead, I can write all these on a paper and give a title DRINK WATER and whenever I say drink water, it would take the paper and read and execuete the instructions automatically.


    3. So what are the advanatges of it?
    When I give the instructions one by one, I must wait till it finishes each one and only then I can give the next. But when I give the full list, I don't have to wait, I just need to tell once and everything would be completed in seconds. As humans we would make mistakes while giving the instructions one by one.


    4. How to record a macro?


    5. Let us create another macro.
    1.Start macro recording.(Tools->Macro-Record new macro)
    2.Enter How r u in the cell A1.
    3.Copy it to the next 19 cells.
    4.Stop recording.
    5.Delete the conents of the cells A1 to A20.
    6.Run the macro(Tools->Macro-Macros)


    6. Is there any other way to create a macro?
    Yes.It is by using VB Editor. It is written in the same way as VB.


    7. How to use it?
    1.Go to Macro->Visual Basic Editor
    2.Start writing your code there.
    3.The name you give for your subroutine is the name of the macro.
    4.To run, go to Macro->Macros->select the name of your macro.


    8. Let us create a macro that will display the name of the current worksheet.
    Go to Macro->Visual Basic Editor
    Write the following code.
    Sub mcrDisplayName()
      MsgBox(ActiveSheet.Name)
    End Sub


    9. Display the name of the current cell.
    Sub mcrDisplayCellName()
      MsgBox (ActiveCell.Address)
    End Sub


    10. Copy the content of cells A1 to A5 to B1.
    Sub mcrCopy()
      Range("a1:a5").Copy Range("b1")
    End Sub


    11. Copy the content of cells A1 to A5 to B1 of another worksheet.
    Sub mcrCopyToSheet()
      Sheets("sheet1").Range("a1:a5").Copy Sheets("sheet2").Range("b1")
    End Sub


    12. To delete a range of cells.
    Sub mcrDelete()
      Range("a1:a5").Clear
    End Sub


    13. To cut and paste in another location.
    Sub mcrCut()
      Range("a1:a5").Select
      Selection.Cut Range("h1")
    End Sub


    14. Let us move further by using For Loop.
    This macro will first show a text box in which you enter a number and then you can hear beeps for that many number of times and message box is shown after each beep.
    Sub BeepSeveral()
    x = InputBox("how many beeps?")
    For counter = 1 To x
       Beep
       MsgBox (counter)
    Next counter
    End Sub


    15. Let us add a If-Else to the example.
    We will first check whether the entered data is a number.If it is so then execute the For-Loop otherwise show a message.
    Sub BeepValidate()
    x = InputBox("how many beeps?")
    If IsNumeric(x) Then
      For counter = 1 To x
         Beep
         MsgBox (counter)
       Next counter
    Else
      MsgBox ("You did not enter a number.")
    End If
    End Sub


    16. An Example for using For-Each.
    In this, the loop is executed for each element in the collection.We dont have to specify a start and end codtion in this case. Let us see an example that will change the color of the font of the numbers below 0 in a specific range of cells.
    Sub mcrChangeColorlt0()
     For Each c In Range("a1:a20").Cells
      If IsNumeric(c.Value) And c.Value<0 Then
         c.Font.Color = RGB(255, 0, 0)
      End If
     Next c
    End Sub


    Enough of Macros.Let's learn something interesting.
    Do you know why is Neptune blue?
    Neptune's atmosphere is made up of hydrogen, helium and methane. The methane in Neptune's upper atmosphere absorbs the red light from the sun but reflects the blue light from the sun back into space. This is why Neptune appear blue. For more info about Neptune click here