Passing a string from .NET to a javascript variable

DreamTeK

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']
DreamTeK

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Passing string variable in Javascript

From Dev

passing multiline string variable from c# to javascript

From Dev

Passing a string from variable as a key in javascript object literal

From Dev

Javascript not passing entire variable string

From Dev

passing a variable from jade to javascript

From Dev

Passing a string from Python to Javascript

From Dev

Passing a string from Python to Javascript

From Dev

passing variable from apex report to javascript function

From Dev

passing a variable to javascript function from code behind

From Dev

Passing Variable from javascript(Ajax) to PHP

From Dev

Passing variable from Javascript to Ruby on Rails

From Dev

passing variable values from c# to javascript

From Dev

Passing variable from php to javascript for use as an ID

From Dev

Rails 4: Passing a variable from controller to javascript

From Dev

Passing variable from Javascript to Ruby on Rails

From Dev

Passing variable to javascript from html with spaces

From Dev

Passing a variable from javascript using $_POST

From Dev

Rails 4: Passing a variable from controller to javascript

From Dev

Passing string variable with spaces

From Dev

Passing a javascript variable (string) to the controller via ajax - 404

From Dev

Passing variable from one form to another in vb.net

From Dev

Passing a variable into a function in javascript

From Dev

Passing a variable by value in Javascript

From Dev

PHP JavaScript passing variable

From Dev

Javascript passing a variable to PHP

From Dev

Passing the JavaScript variable into HTML

From Dev

Passing Javascript Variable in Form

From Dev

Javascript passing variable in function

From Dev

Passing a variable into a function in javascript

Related Related

HotTag

Archive