I'm not sure how to answer your question.
You have essentially just asked how to use
if-conditional statements. If you're having problems with this please check out the link because this topic is pretty straightforward.
However, if you want to execute JavaScript upon a condition in your server-side (C# or VB.NET) code then that's a different story completely.
Please elaborate on your question.
Provide details about what you're trying to do and what you've tried so far to solve the problem.
Especially let us know what your "particular condition" is!
-Frinny