Access variable from code behind via javascript

前端 未结 2 596
终归单人心
终归单人心 2020-12-16 23:04

I have the following code that I want to return to a variable \"t\" in javascript:

Code behind:

Public Shared Function GetSomeText() As String
  Dim          


        
2条回答
  •  [愿得一人]
    2020-12-16 23:43

    Try this -- assuming that this a public method on the page. This will call the method GetSomeText() on the page class and then do a Response.Write() of the data to the page as it's being rendered. The result should end up between the single quotes in your javascript.

     var t = '<%= GetSomeText() %>';
    

提交回复
热议问题