I have the following statement:
btnApply.Attributes.Add("onclick", "alert('Must be a member to Use this Tool')");
Is there a way to add a new line. I tried, but it showed the in the text. In addition, can I add a link that would close the alert and take the user to another page?
How can I do this with my example?
When I added the \n, the alert doesn't show up.
In the alert box, you can use “\n”, to break the sentence into a new line. If you want a linebreak in actual javascript, use the \n escape sequence. Do comment if you knew another way to break the sentence in a new line using JavaScript code or you have any doubts.
You can add HTML into an alert string, but it will not render as HTML. It will just be displayed as a plain string. Simple answer: no.
You can create a custom function that'll replace the native alert() box in the user's web browser. You'll do this from the window object, and the custom function will work as such: Set constants for the alert title and alert button text.
You can't use HTML, but you can add line breaks:
alert('line1\nline2');
If a rich modal popup is really what you want though, you can use jQuery's dialog feature and put whatever you want in there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With