I just have problems with javascript that I use for asp.net code after a few hours it turns out that this is a problem with an escape character.
I use this first.
ScriptManager.RegisterStartupScript(this, this.GetType(), "temp", "alert('Can't delete this data because it is bound with rate plan');", true);
This will result in a javascript error because the quote in “cannot” must use the escape character, which is why I use.
ScriptManager.RegisterStartupScript(this, this.GetType(), "temp", "alert('Can\'t delete this data because it is bound with rate plan');", true);
but it still does not work.
Finally i use
ScriptManager.RegisterStartupScript(this, this.GetType(), "temp", "alert('Can\\'t delete this data because it is bound with rate plan');", true);
and this is normal.
I'm just wondering why we need to use \\'instead \'to make the escape character work correctly.
source
share