Use asp:Literal for JavaScript alert messages
I like to use it like this:
alert('
This gives you the abstraction and flexibility of presenting errMessage to the user in the browser however you see fit, while setting its value in your code-behind file. This particular example uses a JavaScript alert box, but you could easily change that in the code-ahead page to something else, and wouldn't need to change the code-behind file.