Reputation: 25151
I love how in ASP.NET the ScriptManager has a composite section which allows one to specify multiple javascript files and it does the legwork of merging them all into one file at runtime.
I.E.
//input scriptB.js, scriptB.js
ScriptManager.CompositeScript.Scripts.Add("~/scriptA.js")//psuedo code
ScriptManager.CompositeScript.Scripts.Add("~/scriptB.js")//psuedo code
//output
scriptC.js
Is it possible to add javascript source directly to the scriptmanager, E.G.:
ScriptManager.CompositeScript.Scripts.Add("alert('hello');")//psuedo code
Upvotes: 2
Views: 5784
Reputation: 706
It works for me when I do it like this
Private Sub test()
ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "k1", "alert('hello')", True)
End Sub
but when I add SweerAlert to it it wont work
Private Sub test()
ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "k1", "swal('Please Provide All Valid Message Information!')", True)
End Sub
do you have any idea why it dont works.
Upvotes: -1
Reputation: 1321
You could add script through ScriptManager like this:
ScriptManager.RegisterStartupScript(this, GetType(), ClientID,"alert('hello');", true);
This script will be added directly to page.
Upvotes: 2