Copy Code Dim AlertMessage As String AlertMessage = String.Concat("alert('Fields empty.\n Total cannot exceed £", MaxAmount, "');") 'NOTE Response.Write("<script>" & AlertMessage & "</script>") will not show correctly 'Use example below ScriptManager.RegisterStartupScript(Page, Page.GetType, "AlertMessage", AlertMessage, True)
Copy Code Private Sub AlertWindow(ByVal Message As String) Message = Message.Replace("'", "\'") Message = Message.Replace(Convert.ToChar(10), "\n") Message = Message.Replace(Convert.ToChar(13), "") Message = String.Format("window.onload = alert('{0}');", Message) 'Page.ClientScript.RegisterStartupScript(Me.GetType, "PopUpAlert", Message, True) 'Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "PopUpAlert", Message, True) ScriptManager.RegisterStartupScript(Me, Me.GetType, "PopUpAlert", Message, True) End Sub