问题描述:

I've just started a new MVC project in VS 2015 in .NET 4.6

For some reason JavaScript that worked in the last version (VS 2013) is now returning a pop-up 'Do you want to run or save ConfirmFormClick0000.js xx bytes from...' instead of running.

Any ideas why?

Here is the related code that is being run from the controller

 Private Function ModalValidation(Message As String) As JavaScriptResult

Try

Dim SB As New StringBuilder

SB.Append("$body = $('body'); ")

SB.Append("$body.removeClass('loading'); ")

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 JavaScript(SB.ToString)

Catch ex As Exception

'Dim vError As New SendError

'vError.MailError(60, PageName, ex)

End Try

End Function

网友答案:

Turns out the answer is to add

jquery.unobtrusive-ajax.js

It now runs as it should

相关阅读:
Top