I know there have been a lot of posts about this, but I cannot get any of the suggestions like...
Return Content("<script>alert('Hello world!');</script>")
... to work
We are just about to move from MVC to core - this worked in MVC and displayed a bootstrap modal, but I gather support for this method has been dropped in core.
This is what launches the modal 'PopupModal'
Public Function ModalValidation(Message As String) As String
Try
Dim SB As New StringBuilder
SB.Append("$(document).ready(function(){")
SB.Append("$('#PopupModal').modal();")
SB.Append("var vBody = document.getElementById('ModalBodyText');")
SB.Append("vBody.innerHTML = '" & Message & "';")
SB.Append("var vTitle = document.getElementById('ModalTitle');")
SB.Append("vTitle.innerHTML = 'Validation';")
SB.Append("vTitle.style.color = 'orange';")
SB.Append("});")
Return SB.ToString
Catch ex As Exception
EmailError(ex, 170, "Functions")
Return Nothing
End Try
End Function
and on the controller
Private Function Modal(ModalScript As String) As JavaScriptResult
Return JavaScript(ModalScript)
End Function
called like this
Return Modal(ModalValidation("Got here"))
It looks like I can recreate JavaScriptResult like this
Public Class JSResult
Inherits ContentResult
Public Sub New(ByVal script As String)
Me.Content = script
Me.ContentType = "application/javascript"
End Sub
End Class
But then what do I use in place of
Return JavaScript(ModalScript)
Thank you