+ Start a Discussion
Mike FitchMike Fitch 

Question about VisualForce syntax?

How exactly do you comment in VisualForce? // Is for a single line if I'm not mistaken. /* is for more then one line I believe as well. However, I've encountered <-----
also. What does that mean? When it's used, it greys out the code, but the code within still seems to function. Can someone help me with what that means?
Best Answer chosen by Mike Fitch
lakslaks
// does not work in Visualforce. It will just print out the same on your page.

The way to comment out a piece of code is to place it in between <!--   -->

And yes doing the same comments the code, it's not executed anymore. You can remove the commented code blocks once you are done with the development if it's no more required.

Alternatively, you can use the comment tags to add in useful comments about the different sections of code to improve the readability.


Regards,
Lakshmi.

All Answers

lakslaks

Hi Mike,

The way to comment out multiple lines in Visualforce is to use

<!--   (your code goes
         here ..................
         ......................)  -->


The same goes for a single line as well.


Regards,
Lakshmi.

Mike FitchMike Fitch
Can you use // as well for a single line? What are best practices for commenting code?
Mike FitchMike Fitch
Also when using your example:

<!--   (your code goes
         here ..................
         ......................)  -->

That makes the code irrelevant correct? Only for reference I'm assuming.
lakslaks
// does not work in Visualforce. It will just print out the same on your page.

The way to comment out a piece of code is to place it in between <!--   -->

And yes doing the same comments the code, it's not executed anymore. You can remove the commented code blocks once you are done with the development if it's no more required.

Alternatively, you can use the comment tags to add in useful comments about the different sections of code to improve the readability.


Regards,
Lakshmi.

This was selected as the best answer
Mike FitchMike Fitch
Thanks for the clarification. I was confused as to the proper way to handle comments. Thanks again for the help. :)