Javascript alert not working from code behind

后端 未结 3 1691
闹比i
闹比i 2021-01-28 11:29

I am generating a javascript alert box from codebehind in asp.net(vb).

The code:

            Catch ex As Exception
                MesgBox(\"Error in up         


        
3条回答
  •  故里飘歌
    2021-01-28 12:06

    To carry on with the answer given by Pointy, your message contains ' characters, which you need to escape.

    Try this...

      msgedtble = msgedtble.Replace(vbNewLine, "\n").Replace("'","\'")
    

    It is also better to have type='text/javascript' rather than language='javascript'... although this is not absolutely necessary.

提交回复
热议问题