I have tried many ways to pass a string from .net to javascript including .NET serializer, and register startup scripts.
I am looking for the simplest way to populate a javascript variable with a string generated in code behind.
This is what I am currently trying but output is ""
I am open to other suggestions.
VB.NET
Public Property ServerVariable As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim ServerVariable = "'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'"
End Sub
JAVASCRIPT
var data = "<%= ServerVariable %>";
...
List : [data]
DESIRED RESULT
List : ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
Missing get and set values. Passed variable ServerVariable
needs to have a value applied to it.
Private MyVar As String = ""
Public Property ServerVariable As String
Get
Return MyVar
End Get
Set(value As String)
MyVar = value
End Set
End Property
MyVar = "['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments